Sha256: a51c04e0fe9a20b6893cec88f432e28430dc455fafe4a71eb229825dec801931
Contents?: true
Size: 884 Bytes
Versions: 7
Compression:
Stored size: 884 Bytes
Contents
module LibvirtAsync class LogFormatter LOG_FORMAT = "%s, %s [%d/%s/%s] %s\n".freeze DEFAULT_DATETIME_FORMAT = "%F %T.%N".freeze attr_accessor :datetime_format def initialize @datetime_format = nil end def call(severity, time, progname, message) LOG_FORMAT % [ severity[0..0], format_datetime(time), Process.pid, "0x#{Fiber.current.object_id.to_s(16)}", progname, format_message(message) ] end private def format_datetime(time) time.strftime(@datetime_format || DEFAULT_DATETIME_FORMAT) end def format_message(message) case message when ::String message when ::Exception "<#{message.class}>:#{message.message}\n#{(message.backtrace || []).join("\n")}" else message.inspect end end end end
Version data entries
7 entries across 7 versions & 1 rubygems