require "log" require "colorize" struct DebugFormat < Log::StaticFormatter def run string @entry.severity.label[0].downcase string ": " source string ": " message end end struct BaseFormat < Log::StaticFormatter def run io = ::IO::Memory.new color = case @entry.severity when ::Log::Severity::Error Colorize.colorize.red.bold when ::Log::Severity::Warn Colorize.colorize.red.yellow when ::Log::Severity::Notice Colorize.colorize.bold else Colorize.colorize end color.surround(io) do io << @entry.message end string io.to_s end end # Log.define_formatter BaseFormat, "#{severity.to_s.lstrip}(#{source}): #{message}"