Skip to content

Conversation

@irees
Copy link
Contributor

@irees irees commented Dec 25, 2025

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds conditional ANSI color output to the console logger, enabling colored output only when logging directly to a terminal and disabling colors when output is redirected or piped. This improves compatibility with log aggregation tools and file redirection scenarios.

  • Added terminal detection using golang.org/x/term.IsTerminal() to conditionally enable/disable ANSI colors
  • Updated dependencies to include golang.org/x/term package
  • Added comprehensive test script and sample program to verify color behavior in different output scenarios

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
log.go Implements terminal detection to conditionally disable ANSI colors in ConsoleWriter based on stdout file descriptor type
go.mod Updates Go version and adds golang.org/x/term dependency along with updated golang.org/x/sys version
go.sum Adds checksums for new golang.org/x/term and updated golang.org/x/sys dependencies
cmd/testlog/main.go Adds test program demonstrating various logging methods for manual verification
cmd/testlog/test.sh Adds shell script to test color output behavior in different scenarios (terminal, piped, redirected, JSON mode)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@irees irees merged commit 444ca68 into main Dec 25, 2025
4 checks passed
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.

2 participants