Skip to content

Instantly share code, notes, and snippets.

@pechorin
Forked from Filirom1/custom-logger.rb
Created August 19, 2019 20:08
Show Gist options
  • Save pechorin/0f56c764f69f9f5ae6186f8a90200ef8 to your computer and use it in GitHub Desktop.
Save pechorin/0f56c764f69f9f5ae6186f8a90200ef8 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