Skip to content

Replace custom logger with log/slog#2844

Merged
asim merged 6 commits intomasterfrom
copilot/remove-logger-and-add-slog
Feb 3, 2026
Merged

Replace custom logger with log/slog#2844
asim merged 6 commits intomasterfrom
copilot/remove-logger-and-add-slog

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Problem: Debug Log Buffer Functionality Removed

The previous logger implementation was writing log records to debug/log.DefaultLog, which maintained an in-memory buffer of logs. This buffer was used by the Debug handler to provide a Debug.Log endpoint for querying logs.

When the logger was replaced with slog, this functionality was removed.

Plan to Restore Functionality

  • Analyze the issue
    • Review original logger implementation
    • Understand debug/log package purpose
    • Identify Debug.Log endpoint dependency
    • Understand how logs were buffered
  • Design slog-compatible solution
    • Create slog handler that writes to debug/log buffer
    • Integrate handler with logger initialization
    • Maintain backward compatibility
  • Implement the fix
    • Create custom slog handler
    • Update logger to use multi-handler approach
    • Ensure both stdout and debug buffer receive logs
  • Test the implementation
    • Test debug log endpoint works
    • Test log buffering and retrieval
    • Test streaming logs
    • Verify existing tests still pass
  • Code review and validation
    • Request code review
    • Address code review feedback
    • Run security checks

Solution Implemented

Created a multi-handler approach for slog:

  1. debugLogHandler - writes log records to debug/log.DefaultLog buffer with metadata and source info
  2. multiHandler - combines text handler (stdout) and debug handler
  3. Both handlers receive all log records, maintaining original functionality

Code improvements:

  • Extracted extractSourceFilePath helper to eliminate duplication
  • Removed unused buildFormattedOutput function

Testing & Validation

✅ All existing tests pass
✅ New tests verify debug buffer functionality
✅ Integration tests confirm logs are buffered correctly
✅ Debug.Log endpoint can read logs from buffer
✅ Fields and metadata are preserved
✅ No security vulnerabilities detected

All functionality restored with zero breaking changes!

Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE] Remove logger</issue_title>
<issue_description>replace with slog</issue_description>

<agent_instructions>Should we replace the logger with slog?</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 3, 2026 15:33
Co-authored-by: asim <17530+asim@users.noreply.github.com>
Co-authored-by: asim <17530+asim@users.noreply.github.com>
Co-authored-by: asim <17530+asim@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove logger and replace with slog Replace custom logger with log/slog Feb 3, 2026
Copilot AI requested a review from asim February 3, 2026 15:42
Copilot AI and others added 2 commits February 3, 2026 15:50
Co-authored-by: asim <17530+asim@users.noreply.github.com>
Co-authored-by: asim <17530+asim@users.noreply.github.com>
@asim asim marked this pull request as ready for review February 3, 2026 15:55
@asim asim merged commit 4ba40ea into master Feb 3, 2026
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.

[FEATURE] Remove logger

2 participants