Created
January 12, 2017 14:41
-
-
Save Filirom1/1605cc8aa492a9e317cfef2d6e1174c2 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