Created
March 10, 2017 16:05
-
-
Save thbar/eaca5c5f2da8d327f6b44457670ef4d6 to your computer and use it in GitHub Desktop.
A way to log errors in red with Ruby's Logger & the colorize gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source 'https://rubygems.org' | |
| gem 'colorize' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'logger' | |
| require 'colorized_string' | |
| class ColorLogger < Logger | |
| def error(message) | |
| super(ColorizedString[message].colorize(:red)) | |
| end | |
| end | |
| logger = ColorLogger.new(STDOUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment