Structured Logging and TUI Debug Overlay#21
Merged
Conversation
- Add charmbracelet/log dependency (LG.1) - Initialise logger in PersistentPreRunE writing to ~/.wyrd/wyrd.log (LG.2) - Add --log-level flag and WYRD_LOG_LEVEL env var fallback (LG.3) - Thread logger through store via functional options (LG.4) - Thread logger through sync via direct parameter (LG.5) - Thread logger through query engine via functional options (LG.6) - Add TUI debug overlay toggled via :log command (LG.7) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Structured Logging and TUI Debug Overlay
Overview
Adds structured logging throughout the application using charmbracelet/log, with all output directed to
~/.wyrd/wyrd.log. A new TUI debug overlay (:logcommand) lets you inspect the log without leaving the app.Summary
Previously, Wyrd was the strong, silent type — things happened and nobody talked about it. Now it keeps a diary at
~/.wyrd/wyrd.log, meticulously recording every node write, edge deletion, and git push like a particularly conscientious butler. And if you want to read the butler's notes, just type:login the command palette and a monocle-shaped viewport materialises before your eyes.Tip
No steps required after pulling. The logger initialises automatically; log file is created on first run. Use
--log-level debugfor verbose output.Changes
LG.1: Add charmbracelet/log dependency
go.mod/go.sum: Addedgithub.com/charmbracelet/log v1.0.0as a direct dependency.LG.2: Initialise logger in main.go
cmd/wyrd/main.go: AddedPersistentPreRunEthat creates~/.wyrd/and opens~/.wyrd/wyrd.log(O_CREATE|O_WRONLY|O_APPEND, 0644). Creates acharmbracelet/log.New(file)logger stored in a package-levelappLoggervar.internal/tui/app.go: AddedLogger *clog.Loggerfield toConfigandloggerfield toModel.LG.3: --log-level flag and WYRD_LOG_LEVEL env var
cmd/wyrd/main.go: Added--log-levelpersistent flag. Env varWYRD_LOG_LEVELis the fallback; flag takes precedence. Maps "debug"/"info"/"warn"/"error" to the corresponding log levels.LG.4: Thread logger through store
internal/store/store.go: Addedtype Option func(*Store)andWithLogger(*clog.Logger) Option. ChangedNew(path, clock)toNew(path, clock, ...Option). Added nil-guardedlogDebug/logWarnhelpers.internal/store/node.go: Debug logging inWriteNodeandArchiveNode.internal/store/edge.go: Debug logging inWriteEdgeandDeleteEdge.internal/store/watcher.go: Replacedlog/slogwith the store's nil-guarded logger.LG.5: Thread logger through sync
internal/sync/git.go: Added*clog.Loggerparameter toSync(). Debug logging for git commands, info for completion, error for failures. Nil-guarded helper functions.internal/cli/sync.go: AddedLoggerfield toSyncOptions, passed through tosync.Sync().LG.6: Thread logger through query engine
internal/query/engine.go: Addedtype EngineOption func(*Engine)andWithLogger. ChangedNewEngine(index, maxDepth)to accept...EngineOption. Debug logging for query text and row count.LG.7: TUI debug overlay
internal/tui/log_overlay.go: New file.logOverlaystruct withOpen/Close/Update/Viewmethods. Reads last 100 lines from~/.wyrd/wyrd.loginto a viewport. Esc/q to close, scroll keys forwarded to viewport.internal/tui/palette.go: Registered:logcommand inbuiltinCommands().internal/tui/app.go: AddedlogOverlayfield toModel. Wired:logcommand viaopenLogOverlayMsg. Composited overlay inView()usingNewLayer/NewCompositor(same pattern as palette). Input routing when overlay is active.