Skip to content

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Sep 26, 2025

Closes MBA-244

Summary

This PR migrates the GitHub MCP server from the Logrus logging library to Go's standard library log/slog package. The migration maintains existing functionality while modernizing the logging infrastructure and removing an external dependency.

Key Changes:

  • Replaced github.com/sirupsen/logrus with log/slog in server initialization
  • Updated IOLogger interface to work with slog instead of Logrus
  • Migrated from format string logging to structured key-value logging
  • Removed Logrus dependency from go.mod

Implementation Details

Server Logging (internal/ghmcp/server.go):

  • Logger creation now uses slog.New() with conditional file handler vs slog.Default()
  • File logging uses slog.NewTextHandler() with debug level
  • Stdlib logger bridge uses slog.NewLogLogger() instead of logrus.Writer()
  • Shutdown logging changed from logrusLogger.Infof() to logger.Info()

IOLogger Migration (pkg/log/io.go):

  • Constructor now accepts *slog.Logger instead of *logrus.Logger
  • Changed from format strings to structured logging:
    • l.logger.Infof("[stdin]: received %d bytes: %s", n, data)l.logger.Info("[stdin]", "received_bytes", n, "data", data)
    • l.logger.Infof("[stdout]: sending %d bytes: %s", len(p), data)l.logger.Info("[stdout]", "sending_bytes", len(p), "data", data)

Tradeoffs

Taken On:

  • Log format changes: Structured logging output will differ from previous format strings, which may require updates to log parsing systems
  • API breaking change: IOLogger constructor signature changed (internal API only)

Paid Down:

  • Dependency reduction: Removed external Logrus dependency in favor of stdlib
  • Modernization: Using Go's official structured logging approach introduced in Go 1.21

⚠️ Review Focus Areas

  1. Log Output Format: Verify the new structured logging format is acceptable for downstream log consumers
  2. File Logging Behavior: Test actual file logging functionality (couldn't be fully tested due to missing GitHub token)
  3. IOLogger Compatibility: Confirm structured logging format meets expectations for stdin/stdout logging
  4. Stdlib Bridge: Validate slog.NewLogLogger() provides equivalent functionality to previous log.New(logrusLogger.Writer())
  5. Error Handling: Ensure slog handles file operations and error cases equivalently to Logrus

Session: https://app.devin.ai/sessions/559e5a86ce774440ab207ce212e315a4
Requested by: @jakexcosme

- Replace github.com/sirupsen/logrus import with log/slog in server.go
- Update logger creation to use slog.New() with slog.NewTextHandler() for file logging
- Use slog.Default() when no log file path is specified
- Replace logrusLogger.Writer() bridge with slog.NewLogLogger() for stdlib compatibility
- Update shutdown logging to use logger.Info() instead of logrusLogger.Infof()
- Update IOLogger interface in pkg/log/io.go to accept *slog.Logger instead of *logrus.Logger
- Change IOLogger logging methods to use structured logging with key-value pairs
- Update IOLogger tests to use slog.NewTextHandler() instead of logrus setup
- Remove unused standard library log import

All existing logging functionality is preserved while migrating to Go's standard slog package.

Co-Authored-By: Jake Cosme <jake@cognition.ai>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

After migrating to slog, the github.com/sirupsen/logrus dependency
is no longer needed and has been removed by go mod tidy.

Co-Authored-By: Jake Cosme <jake@cognition.ai>
@sonarqubecloud
Copy link

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.

0 participants