Repository navigation
Add structured logging with configurable levels and formats - #5
Merged
Merged
Conversation
Introduce a logging package and wire it through the CLI, the Vault client and vaultsync. - New global options --log-level (error|warn|info|debug|trace, default info) and --log-format (text|json), also read from VAULT_MANAGER_LOG_LEVEL / VAULT_MANAGER_LOG_FORMAT; flags win. Both "--log-level debug" and "--log-level=debug" are accepted. Invalid values fail with a usage error. - Logs go to stderr only; command output, diffs, prompts and exit codes are unchanged. With the default level nothing new is printed. - Runner logs command start/completion/failure at debug with the command name and argument count only (never argument values). - Vault client: replace vaultkv's raw request/response dump with a tracing transport that logs method, redacted URL, status and duration at trace. Tokens, headers and bodies are never logged. Read/Write/Delete log paths and key counts at debug. - vaultsync Pull/Plan/Apply take an explicit logger and log stages, paths, per-secret decisions and counts at debug. - DEBUG is deprecated: with no level set it maps to trace and warns. - Docs (README, commands, sync, docker), envvars help, and Makefile sync-pull/sync-plan/sync-apply targets that require VAULT_PATH and LOCAL_DIR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016mgmWtAUXMBCJLCHSP2bjZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a comprehensive logging system to vault-manager, replacing ad-hoc debug output with structured, configurable diagnostic logging.
Summary
Adds a new
loggingpackage that provides structured logging via Go's standardlog/sloglibrary, with support for multiple log levels (error, warn, info, debug, trace) and output formats (text, JSON). Logging is written to stderr by default, keeping stdout clean for command output and scripting. The system integrates throughout the codebase to provide diagnostic information at appropriate verbosity levels.Key Changes
New logging package (
logging/logging.go):ParseLevel()andParseFormat()for configuration validationNew()to create configured loggersSetup()to handle legacyDEBUGenvironment variable with deprecation warningLevelTraceconstant for sub-debug verbosity with HTTP tracingKeyCommand,KeyPath,KeyCount, etc.) for consistent loggingHTTP tracing (
vault/trace.go):tracingTransportmiddleware logs HTTP method, redacted URL, status, and duration at trace levelRedactURL()strips user info and masks sensitive query parameters (token, secret, password, etc.)Command-line integration:
--log-leveland--log-formatflags incmd/options.goVAULT_MANAGER_LOG_LEVELandVAULT_MANAGER_LOG_FORMATExpandFlagAssignments()handles--flag=valuesyntaxVault client logging (
vault/vault.go):LoggerinVaultConfigSync operations logging (
vaultsync/plan.go,pull.go,apply.go):Runner logging (
app/runner.go):Documentation:
Notable Implementation Details
OrDiscard()provides a no-op logger when neededLevelTraceis rendered as "TRACE" in output viareplaceLevelName()attribute handlerDEBUG=1environment variable maps to trace level with deprecation warninghttps://claude.ai/code/session_016mgmWtAUXMBCJLCHSP2bjZ