-
-
Save pechorin/0f56c764f69f9f5ae6186f8a90200ef8 to your computer and use it in GitHub Desktop.
How to customize a logger in ruby
This file contains 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' | |
module Dim | |
class Logger < ::Logger | |
def initialize(*) | |
super | |
@formatter = NoTimestampFormatter.new | |
end | |
end | |
class NoTimestampFormatter < ::Logger::Formatter | |
def call(severity, time, progname, msg) | |
format % [ | |
severity, | |
msg2str(msg).strip | |
] | |
end | |
def format | |
"%s: %s\n" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment