Migrate daemon logging to log/slog#323
Merged
nicobistolfi merged 1 commit intomainfrom Mar 26, 2026
Merged
Conversation
Replace the custom AppendDaemonLog printf-style logging callback with Go's standard log/slog package as the primary daemon logging path. - Add internal/logging package with NewDaemonLogger (file-backed slog.TextHandler with local-timezone RFC3339 timestamps) and Discard helper for tests. - Replace LoggingRunner.Logf callback with Logger *slog.Logger field, emitting structured attributes (cmd, dir, err, output) instead of preformatted strings. - Convert all 124 AppendDaemonLog call sites in app.go to structured slog.Info/slog.Error calls with typed key-value attributes. - Update ListIssueCommentsForPolling in github.go to accept *slog.Logger instead of a logf callback. - Wire the slog logger in App.New() and pass it to both the App struct and LoggingRunner. - Update test assertions in environment_test.go and app_test.go to match the new slog TextHandler output format. - Preserve access log (access.jsonl) behavior unchanged. - Daemon log remains at ~/.vigilante/logs/vigilante.log with human-readable text output. Closes #321
6 tasks
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
AppendDaemonLogprintf-style logging with Go's standardlog/slogpackage as the primary daemon logging pathinternal/loggingpackage withNewDaemonLogger(file-backedslog.TextHandler) andDiscardhelperAppendDaemonLogcall sites inapp.goto structuredslog.Info/slog.Errorwith typed key-value attributesLoggingRunner.Logfcallback withLogger *slog.Loggerfield for structured command lifecycle loggingWhat changed
internal/logging/NewDaemonLoggercreates a file-backed slog logger with local-timezone RFC3339 timestamps;Discardreturns a no-op logger for testsinternal/environment/LoggingRunner.Logf func(format string, args ...any)→Logger *slog.Logger;Run()andLookPath()emit structured slog attributesinternal/app/Appgains alogger *slog.Loggerfield wired inNew(); all 124a.state.AppendDaemonLog(...)calls converted toa.logger.Info/Error(...)with structured attributesinternal/github/ListIssueCommentsForPollingaccepts*slog.Loggerinstead oflogfcallbackenvironment_test.goandapp_test.goupdated to assert on slog TextHandler output formatWhat is preserved
~/.vigilante/logs/vigilante.login human-readable text formataccess.jsonl) behavior is completely unchangedvigilante logscontinues to surface the expected filesstate.Store.AppendDaemonLogremains available for any future callersTest plan
go test ./...— all tests passgofmt -l .— no formatting issuesgo vet ./...— no issuesgo build ./...— clean buildCloses #321