Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorize logs in dev #894

Merged
merged 3 commits into from
Nov 13, 2024
Merged

Colorize logs in dev #894

merged 3 commits into from
Nov 13, 2024

Conversation

santib
Copy link
Member

@santib santib commented Nov 12, 2024

Taken from https://gist.github.com/kyrylo/3d90f7a656d1a0accf244b8f1d25999b

Improves logs legibility by colorizing them by the log level

Another additional gem that may be worth adding (but requires more manual setup) is https://github.com/mechanicles/colorize_logs

BEFORE:
image

AFTER:
image

Copy link
Contributor

@JulianPasquale JulianPasquale left a comment

Choose a reason for hiding this comment

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

😎

@santib santib requested a review from a team November 12, 2024 16:47
Copy link
Contributor

@enzofab91 enzofab91 left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@blacksam07 blacksam07 left a comment

Choose a reason for hiding this comment

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

LGTM, only include a freeze for a constant

and just only for fun you can use define_method to create all repetitive methods

    COLOR_CODES.keys.each do |level|
      define_method(level) do |progname = nil, &block|
        super(colorize(level, progname, &block))
      end
    end

config/initializers/colorized_logger.rb Show resolved Hide resolved
Copy link
Contributor

@mrodriguez90 mrodriguez90 left a comment

Choose a reason for hiding this comment

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

🌈 🌈

@santib santib merged commit 7ed2703 into main Nov 13, 2024
3 checks passed
@santib santib deleted the colorize-logs-in-dev branch November 13, 2024 15:15
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.

5 participants