Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ KeyLint is a desktop app that fixes/enhances clipboard text via AI (OpenAI, Anth

**Reference docs:** `.claude/docs/architecture.md` (service wiring, RPC bridge, platform differences), `.claude/docs/testing.md` (detailed patterns), `.claude/docs/versioning.md` (release pipeline, CI)

**Logging conventions:** `docs/logging.md` (levels, Redact() usage, source tagging, CLI flags)

**Pyramidize docs:** `docs/pyramidize/` (requirements, ADR, quality status, NLP/LangChain research, UX roadmap)
51 changes: 51 additions & 0 deletions docs/logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Logging Conventions

## Log Levels

| Level | When to use |
|---------|------------------------------------------------|
| off | Default. No logging. |
| trace | Verbose internals, hot-path detail |
| debug | Diagnostic info for developers |
| info | Normal operational events |
| warning | Recoverable issues |
| error | Failures requiring attention |

## Sensitive Redaction

**Rule:** If a log value could contain user text, API payloads, or credentials, wrap it in `logger.Redact()`.

```go
// Safe metadata — no wrapping needed
logger.Info("enhance: start", "provider", cfg.ActiveProvider, "input_len", len(text))

// Sensitive data — wrap in Redact()
logger.Debug("enhance: request", "provider", "openai", "payload", logger.Redact(string(body)))
```

When `SensitiveLogging` is off, `Redact()` outputs `[redacted]`. When on, the real value is shown. Uses slog's native `LogValuer` interface.

Never wrap: provider names, status codes, byte lengths, error messages, config keys.
Always wrap: API request/response bodies, user text, clipboard content, API keys.

## Source Tagging

All log entries include a `source` attribute:
- `source=backend` — Go backend (automatic via default logger instance)
- `source=frontend` — Angular frontend (via the log bridge service)

## CLI Usage

```bash
./bin/KeyLint -fix --log debug "text to fix"
./bin/KeyLint -pyramidize --log info -f input.md
```

Valid levels: `off`, `trace`, `debug`, `info`, `warning`, `error`. Default: `off`.
Sensitive logging is always off in CLI mode to prevent credential leaks to terminal.

## Settings

- **UI:** Settings > General > Log Level dropdown (Off/Trace/Debug/Info/Warning/Error)
- **JSON field:** `"log_level": "off"` (replaces legacy `"debug_logging": true/false`)
- **Migration:** Legacy `debug_logging: true` is auto-migrated to `log_level: "debug"` on load
Loading
Loading