Skip to content

Instantly share code, notes, and snippets.

@Filirom1
Created January 12, 2017 14:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Filirom1/1605cc8aa492a9e317cfef2d6e1174c2 to your computer and use it in GitHub Desktop.
Save Filirom1/1605cc8aa492a9e317cfef2d6e1174c2 to your computer and use it in GitHub Desktop.
How to customize a logger in ruby
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