Skip to content

Make terminal logging colorful 馃寛 - #295

Merged
CorentinB merged 1 commit into
mainfrom
colorful-logging-life
May 24, 2025
Merged

Make terminal logging colorful 馃寛#295
CorentinB merged 1 commit into
mainfrom
colorful-logging-life

Conversation

@yzqzss

@yzqzss yzqzss commented May 23, 2025

Copy link
Copy Markdown
Collaborator

image

Now my eyes can easily spot the warn/error logs from the terminal stream.

Also added --no-color-logs flag to disable this feature. (to switch back to [slog] handler)


This PR only colors the stdout and stderr terminal logging handlers and does not affect the file logging handler (/jobs/{job}/log/ZENO-{time}.log).


The [slogcolor] handler's output format is slightly different from slog. For example, it does not escape the " to \" in the log message.


Introduced lib:

@yzqzss
yzqzss requested a review from Copilot May 23, 2025 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces colorful terminal logging to enhance visibility of warn/error logs, while also adding an option to disable color output via a flag.

  • Added integration with slogcolor and fatih/color libraries to render colorful logs.
  • Introduced a new flag (--no-color-logs) in the command line and corresponding config options.
  • Modified logging handler implementations to choose between standard and colorized output.

Reviewed Changes

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

Show a summary per file
File Description
internal/pkg/log/fielded_logger.go Updated log method to replicate slog.Logger behavior with colors.
internal/pkg/log/config.go Added new color-specific handler and configuration options.
internal/pkg/config/config.go Introduced configuration for disabling color logging.
go.mod Added required dependencies for color logging.
cmd/cmd.go Added CLI flag for turning off colorized logging.

@yzqzss yzqzss changed the title Make terminal logs colorful 馃寛 Make terminal logging colorful 馃寛 May 23, 2025
also added --no-color-logs flag to disable this
@yzqzss
yzqzss force-pushed the colorful-logging-life branch from fca7542 to 889b78c Compare May 23, 2025 17:22
@yzqzss
yzqzss requested review from CorentinB and NGTmeaty May 23, 2025 17:25

@NGTmeaty NGTmeaty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's so much easier to read. Thank you! LGTM!

@CorentinB CorentinB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome! LGTM!

@CorentinB
CorentinB merged commit 1b71cdd into main May 24, 2025
@yzqzss
yzqzss deleted the colorful-logging-life branch June 14, 2025 15:57
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.

4 participants