Skip to content

Migrate daemon logging to log/slog#323

Merged
nicobistolfi merged 1 commit intomainfrom
vigilante/issue-321-migrate-vigilante-logging-to-log-slog
Mar 26, 2026
Merged

Migrate daemon logging to log/slog#323
nicobistolfi merged 1 commit intomainfrom
vigilante/issue-321-migrate-vigilante-logging-to-log-slog

Conversation

@nicobistolfi
Copy link
Copy Markdown
Collaborator

Summary

  • Replace custom AppendDaemonLog printf-style logging with Go's standard log/slog package as the primary daemon logging path
  • Add internal/logging package with NewDaemonLogger (file-backed slog.TextHandler) and Discard helper
  • Convert all 124 AppendDaemonLog call sites in app.go to structured slog.Info/slog.Error with typed key-value attributes
  • Replace LoggingRunner.Logf callback with Logger *slog.Logger field for structured command lifecycle logging

What changed

Area Change
internal/logging/ New package: NewDaemonLogger creates a file-backed slog logger with local-timezone RFC3339 timestamps; Discard returns a no-op logger for tests
internal/environment/ LoggingRunner.Logf func(format string, args ...any)Logger *slog.Logger; Run() and LookPath() emit structured slog attributes
internal/app/ App gains a logger *slog.Logger field wired in New(); all 124 a.state.AppendDaemonLog(...) calls converted to a.logger.Info/Error(...) with structured attributes
internal/github/ ListIssueCommentsForPolling accepts *slog.Logger instead of logf callback
Tests environment_test.go and app_test.go updated to assert on slog TextHandler output format

What is preserved

  • Daemon log still writes to ~/.vigilante/logs/vigilante.log in human-readable text format
  • Access log (access.jsonl) behavior is completely unchanged
  • vigilante logs continues to surface the expected files
  • state.Store.AppendDaemonLog remains available for any future callers

Test plan

  • go test ./... — all tests pass
  • gofmt -l . — no formatting issues
  • go vet ./... — no issues
  • go build ./... — clean build
  • Environment tests validate slog-based command logging (start, ok, failed, output suppression)
  • App tests validate daemon log file content with slog format (polling summaries, suppressed raw commands, failure diagnostics)

Closes #321

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
@nicobistolfi nicobistolfi merged commit c533db0 into main Mar 26, 2026
1 check passed
@nicobistolfi nicobistolfi deleted the vigilante/issue-321-migrate-vigilante-logging-to-log-slog branch March 26, 2026 18:27
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.

Migrate Vigilante logging to log/slog

1 participant