Repository navigation
feat: log every command to a daily file with tracing - #226
Merged
Merged
Conversation
Replace env_logger with tracing-subscriber. The terminal keeps
env_logger's behaviour; every command also appends info and above to
~/.atomic/logs/atomic.YYYY-MM-DD.log, one line per event with the pid
and spans. git import logs each commit in a commit{n, of, sha} span
with its duration, and the write loop's decisions.
Add spans to bridge reconcile, switch, import_head, export, verify and pre-push, with the reconcile observation and direction and each switch step. Copy the evidence Git's hooks journal, every consented bridge event, and the CLI's status messages into the log file. None of these change what the commands do or print.
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.
Summary
atomiccommand now writesinfoand above to~/.atomic/logs/atomic.YYYY-MM-DD.log. The terminal output is unchanged.git importlogs each commit in its own span, with how long it took and the decisions the importer made for it.Why
tracingcrate to GitBridge withinfologging for all commands. This PR applies it to every CLI command and writes it to a file, so we can read what actually happened.log+env_logger: warnings on the terminal, nothing written anywhere.ATOMIC_TRACE_GIT_IMPORT) went to stderr only when that variable was set, with no timestamps, threads or file.What changed
Logging backend (
atomic-cli/src/logging/)tracing-subscriberreplacesenv_logger. Only the initialisation changed: the ~435 existinglog::calls reach it unchanged throughtracing-log.-vshowsatomic=debug,atomic_core=info.RUST_LOGwins.[time LEVEL target] messageshape.-v.h2/hyper/hyper_util, which log throughtracingnatively; nothing collected their events before.RUST_LOGwith no usable directive shows errors, as env_logger did.infoand above to~/.atomic/logs/atomic.YYYY-MM-DD.log(underATOMIC_CONFIG_DIRwhen set).ATOMIC_LOGsets the file's filter (offdisables it).ATOMIC_LOG_DIRmoves the file; it must be an absolute path, so a relative one never lands in a repository.O_APPENDwrite, so it is on disk when the call returns. Nothing is buffered to flush at exit, a panic or a signal.tracing-appender's background writer: on shutdown timeout it prints to stdout (it would break--jsonoutput), it aborts startup if it cannot spawn its thread, and it drops lines silently when its queue fills. At a few lines per command the synchronous write costs nothing measurable (numbers below).time pid=N LEVEL ThreadId(N) spans: target: message.atomic{cmd=git import}, with the command's start (version, cwd), finish (outcome, exit code, error) and duration.0700.user:password@, query and fragment before they are logged. Remote errors name the URL, and remote URLs can carry credentials.ATOMIC_LOG_DIRgives one warning and the command runs normally. An unusable default location stays quiet (visible with-v). Panics are also logged to the file.Git import
trace_git_import: phase timings, per-commitwrite/parselines, reclassified paths) now go to the file atinfo, targetatomic::git::import.ATOMIC_TRACE_GIT_IMPORTstill prints them on the terminal.preflight,parse,import,write, and onecommit{n, of, sha}per commit.Example (3-commit import):
The commit span's 458ms against the ~1ms of timed phases is the untimed per-commit cost #225 went after. The log now shows that gap per commit.
Not in this PR
atomic-repository(verification, materialization) and redb (open, lock wait, commit). These are the next step.enable,reconcile,verify, …).ATOMIC_TRACE_*/ATOMIC_DEBUG_*switches stay as they are.Tests
atomic-cli/tests/logging_integration_test.rs, 9):ATOMIC_LOG=off,ATOMIC_LOG_DIR,ATOMIC_CONFIG_DIR;-vstill shows thelogmacros' debug lines in env_logger's shape, without the file-only lines, andRUST_LOGwins over-v;git importlogs each commit'swriteline and duration insidecommit{n, of, sha}.RUST_LOGthat does not parse still shows errors;0700;cargo test -p atomic-cli: 2412 pass. The 6 that fail locally fail identically on990612c:--features adoption-test-injection. With it they pass on this branch (git_bridge_cb13d_test21/21,graph_only_export_cb9b_test3/3).cargo fmt --checkpasses.cargo clippy -p atomic-cli --all-targets -D warningsreports nothing new; the local 1.95 toolchain flags existing sites (materialize.rs,record.rs,collapsible_match,git_projection_cb8a_test.rs) identically on990612c.ATOMIC_LOG=off: