lib/tobox/configuration.rb in tobox-0.1.0 vs lib/tobox/configuration.rb in tobox-0.1.1
- old
+ new
@@ -23,10 +23,18 @@
shutdown_timeout: 10,
concurrency: 4, # TODO: CPU count
worker: :thread
}.freeze
+ LOG_FORMAT_PATTERN = "%s, [%s #%d (th: %s)] %5s -- %s: %s\n"
+ DEFAULT_LOG_FORMATTER = Class.new(Logger::Formatter) do
+ def call(severity, time, progname, msg)
+ format(LOG_FORMAT_PATTERN, severity[0, 1], format_datetime(time), Process.pid,
+ Thread.current.name || Thread.current.object_id, severity, progname, msg2str(msg))
+ end
+ end.new
+
def initialize(name = nil, &block)
@name = name
@config = DEFAULT_CONFIGURATION.dup
@lifecycle_events = {}
@@ -44,10 +52,10 @@
raise Error, "configuration does not support blocks with more than one variable"
end
end
env = @config[:environment]
- @default_logger = @config[:logger] || Logger.new(STDERR) # rubocop:disable Style/GlobalStdStream
+ @default_logger = @config[:logger] || Logger.new(STDERR, formatter: DEFAULT_LOG_FORMATTER) # rubocop:disable Style/GlobalStdStream
@default_logger.level = @config[:log_level] || (env == "production" ? Logger::INFO : Logger::DEBUG)
freeze
end