Skip to content

Conversation

Copy link

Copilot AI commented Nov 12, 2025

Replaces logrus with Go's standard library log/slog for structured logging with configurable log levels. Debug logs are now enabled via DEBUG=1 environment variable.

Implementation

  • New logging abstraction (pkg/logging/)

    • SlogLogger: Wraps log/slog, implements Logger interface
    • LogrusAdapter: Maintains compatibility for existing logrus usage
    • Logger interface: Implementation-agnostic (no longer tied to *logrus.Entry)
  • Main initialization (main.go)

    • Added initLogger() to configure log level from DEBUG env var
    • Sets slog.LevelDebug when DEBUG=1, otherwise slog.LevelInfo
  • Updated dependencies

    • ClientConfig.Logger now uses logging.Logger interface
    • Removed hardcoded logrus level manipulation in pkg/metrics
    • All tests updated to use new interface

Usage

# Enable debug logging
DEBUG=1 ./model-runner

# Docker
docker run -e DEBUG=1 docker/model-runner:latest

Log output format:

time=2025-11-12T15:55:44.435Z level=INFO msg="Successfully initialized store" component=model-manager
time=2025-11-12T15:55:44.435Z level=DEBUG msg="Loading model from cache" model=llama-3

Structured logging still supported:

log.WithFields(map[string]interface{}{
    "component": "backend",
    "model": "llama-3",
}).Debug("Model loaded")
Original prompt

This section details on the original issue you should resolve

<issue_title>Introduce log levels with slog</issue_title>
<issue_description>There is a library in stdlib that is ideal for this, --debug should print all the debug-level logs:

https://pkg.go.dev/log/slog</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 12, 2025 15:56
- Add slog-based logger wrapper (SlogLogger) that implements the logging.Logger interface
- Create LogrusAdapter to maintain compatibility with existing logrus code
- Replace logrus with slog in main.go, controlled by DEBUG environment variable
- Update logging.Logger interface to be implementation-agnostic
- Update all test files to use the new logging interface
- Maintain backward compatibility with existing code using logrus

Co-authored-by: ericcurtin <[email protected]>
- Add comprehensive tests for SlogLogger (debug levels, fields, errors, fatal handling)
- Add logging.md documentation explaining how to use DEBUG mode
- All tests pass successfully

Co-authored-by: ericcurtin <[email protected]>
Copilot AI changed the title [WIP] Introduce log levels using slog library Introduce log levels with slog Nov 12, 2025
Copilot AI requested a review from ericcurtin November 12, 2025 16:06
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.

Introduce log levels with slog

2 participants