lib/timber/logger.rb in timber-2.1.0.rc2 vs lib/timber/logger.rb in timber-2.1.0.rc3
- old
+ new
@@ -1,8 +1,9 @@
require "logger"
require "msgpack"
+require "timber/config"
require "timber/current_context"
require "timber/event"
require "timber/log_devices/http"
require "timber/log_entry"
@@ -193,18 +194,24 @@
# Ensure we sync STDOUT to avoid buffering
if args.size == 1 and args.first.respond_to?(:"sync=")
args.first.sync = true
end
+ # Set the default formatter. The formatter cannot be set during
+ # initialization, and can be changed with #formatter=.
if args.size == 1 and args.first.is_a?(LogDevices::HTTP)
self.formatter = PassThroughFormatter.new
+ elsif Config.instance.development? || Config.instance.test?
+ self.formatter = MessageOnlyFormatter.new
else
self.formatter = AugmentedFormatter.new
end
self.level = environment_level
after_initialize if respond_to?(:after_initialize)
+
+ Timber::Config.instance.debug { "Timber::Logger instantiated, level: #{level}, formatter: #{formatter.class}" }
@initialized = true
end
# Sets a new formatted on the logger.
\ No newline at end of file