feat(logging): migrate from debug_log to tracing with production logging#1078
Open
feat(logging): migrate from debug_log to tracing with production logging#1078
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Migrating from hand-rolled debug_log() to tracing crate with proper log levels, custom Sentry-forwarding Layer, and structured production output across the entire codebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
10-task plan covering tracing infrastructure, SentryLayer, level promotions, codebase-wide debug_log migration, and new production log points for git write ops, checkpoints, and auto-updater. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Thin tracing::Layer impl that intercepts ERROR-level events and forwards them to the existing telemetry worker as TelemetryEnvelope::Error events, routing to both enterprise and OSS Sentry DSNs automatically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sets up tracing with EnvFilter (info default, debug when GIT_AI_DEBUG=1), fmt layer writing to stderr (which dup2 redirects to log file), and SentryLayer for automatic error forwarding. Adds daemon started/shutdown lifecycle log lines. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… promotions Convert all 75 debug_log() calls to tracing macros with appropriate levels: ERROR for panics/socket failures, WARN for recoverable failures, INFO for key operations (updater, restart, lifecycle), DEBUG for everything else. Replace 16 observability::log_error() calls with tracing::error!() that includes structured context fields (SentryLayer handles forwarding). Add new INFO-level log points: - Git write ops: commit/rebase/merge/cherry-pick/am/stash/reset/push - Checkpoint start/done with timing - Shutdown reasons Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ase-wide Convert 500+ debug_log/debug_performance_log/debug_performance_log_structured calls across 42 files to tracing::debug!(). Covers authorship, commands, hooks, git, mdm, config, observability, and telemetry_worker modules. All calls become tracing::debug!() with no level promotions outside of daemon.rs (which was done in a prior commit). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove debug_log(), debug_performance_log(), debug_performance_log_structured(), and all supporting code (is_debug_enabled, DEBUG_ENABLED, DEBUG_PERFORMANCE_LEVEL, etc.). All call sites have been migrated to tracing macros. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 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.
Summary
debug_log()to thetracingcrate with proper log levels (tracing::error!,tracing::warn!,tracing::info!,tracing::debug!)tracing::error!()events to Sentry via the existing telemetry worker pipeline — no manual dual-calls needed at error sitesdebug_loginfrastructure entirely fromutils.rs— one call pattern (tracing::*!()) across the entire codebaseWhat gets logged in production (INFO level):
What gets logged as errors (ERROR → Sentry):
What stays debug-only:
Changes
debug_log()+ 15debug_performance_log()+ 2debug_performance_log_structured()calls convertedobservability::log_error()calls in daemon.rs replaced bytracing::error!()with structured context fields (SentryLayer handles forwarding)src/daemon/sentry_layer.rs— custom tracing Layer for Sentry error forwardingtracing 0.1,tracing-subscriber 0.3(withenv-filterfeature)Test plan
cargo checkpassescargo test— all unit tests passcargo test --test daemon_mode— all 54 daemon integration tests passdebug_log/debug_performance_logreferences in codebase~/.git-ai/internal/daemon/logs/{PID}.logshows INFO-level outputgit-ai bg tailshows formatted log outputFollow-up items
sentrycrate withsentry-tracingLayer (replaces custom SentryLayer + custom SentryClient)TelemetryEnvelope::Performanceevents to tracing spans for standard Sentry performance monitoring🤖 Generated with Claude Code