Skip to content

feat(cli): leveled logger + --verbose/--quiet flags - #8

Merged
ironystock merged 1 commit into
refactor/cmd-rememberize-splitfrom
feat/cli-leveled-logger
Apr 28, 2026
Merged

ironystock merged 1 commit into
refactor/cmd-rememberize-splitfrom
feat/cli-leveled-logger

Conversation

@ironystock

@ironystock ironystock commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds charmbracelet/log as the package-level structured logger.
  • New persistent flags on rootCmd: -v/--verbose (count) and --quiet.
  • Stdout reserved for data; logs always go to stderr.
  • Two instrumentation sites: client.do() debug logs around the HTTP round-trip, and config.loadConfig's parse-warning swapped to logger.Warn.

Stacking

This PR is stacked on #7 (refactor split). Base = refactor/cmd-rememberize-split. When #7 merges to main, GitHub will automatically retarget this PR's base to main.

Level matrix

Flags Level
(default) WARN
-v INFO
-vv (or more) DEBUG
--quiet ERROR
--quiet -vv ERROR (quiet wins)
--json alone (logs silenced; stdout pristine)
--json -v JSON-formatted logs to stderr

Files

cmd/rememberize/
  log.go         NEW — package-level logger + configureLogger()
  log_test.go    NEW — TestConfigureLogger_LevelMatrix (8 sub-tests)
  main.go        +4 lines (flag registration + cobra.OnInitialize)
  client.go      +3 lines (3 logger.Debug sites in do())
  config.go      stderr write → logger.Warn
go.mod / go.sum  +charmbracelet/log v1.0.0 (pulls lipgloss + termenv as transitives — useful in later PRs)

Verification

  • go build ./... clean.
  • go test ./... green (new test passes; existing pair tests untouched).
  • go vet ./... clean.
  • Smoke: ./bin/rememberize --help shows the two new flags.

Heads-up: tiny breaking change

Cobra previously bound -v to --version. After this PR, -v means --verbose. The long form --version still works. Anyone scripting rememberize -v to get the version will now see verbose-mode output (with no command). Universal CLI convention favors -v for verbose; the long-form --version is the supported scripting path.

Test plan

  • CI green across the board.
  • Manual: rememberize -vv list (against a configured server) shows DEBUG http request and DEBUG http response lines on stderr; bare rememberize list shows none.
  • Manual: rememberize --json list produces clean JSON on stdout (no log noise).

What's next (not this PR)

PR 3 wraps the cobra root with charmbracelet/fang for styled --help/--version. PR 4 swaps text/tabwriter for lipgloss tables. PR 5 swaps bufio prompts for huh in the pair flow.

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Adds charmbracelet/log as the package-level structured logger and wires
two new persistent flags on rootCmd:

  -v, --verbose count  (1 = info, 2+ = debug; default = warn)
      --quiet          (overrides -v, clamps to error only)

Output discipline: logs always go to stderr; stdout stays reserved for
command output users may pipe (lists, JSON, success lines). With
--json and no -v, logs are silenced entirely so the JSON stream stays
pristine for jq/scripting; --json with -v flips the formatter to JSON
on stderr.

Two instrumentation sites in this PR:

- client.do() now emits debug logs on http request entry, exit, and
  failure (method, url, status / err). Every command that goes through
  the shared do() path picks this up automatically.
- config.loadConfig()'s prior "warning: could not parse config file"
  stderr write is now a structured logger.Warn — visible at default
  level since warnings still emit.

Other fmt.Print* sites untouched: they're user-facing data, not logs.

Tests: TestConfigureLogger_LevelMatrix exercises the precedence matrix
across {default, -v, -vv, -vvv, --quiet, --quiet+-vv, --json,
--json+-v}. Existing pair tests untouched.

Note for users: cobra previously bound -v to --version. -v now means
--verbose; --version still works in long form.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ironystock
ironystock merged commit 56bc137 into refactor/cmd-rememberize-split Apr 28, 2026
ironystock added a commit that referenced this pull request Apr 28, 2026
feat(cli): leveled logger + fang wrap (re-merge of #8 + #9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant