lib/timber/logger.rb in timber-2.6.2 vs lib/timber/logger.rb in timber-3.0.0

- old
+ new

@@ -1,11 +1,10 @@ require "logger" require "msgpack" require "timber/config" require "timber/current_context" -require "timber/event" require "timber/log_devices" require "timber/log_entry" module Timber # The Timber Logger behaves exactly like the standard Ruby `::Logger`, except that it supports a @@ -37,23 +36,21 @@ level = SEVERITY_MAP.fetch(severity) tags = extract_active_support_tagged_logging_tags if logged_obj.is_a?(Event) LogEntry.new(level, time, progname, logged_obj.message, context_snapshot, logged_obj, - tags: tags) + tags: tags) elsif logged_obj.is_a?(Hash) # Extract the tags tags = tags.clone tags.push(logged_obj.delete(:tag)) if logged_obj.key?(:tag) tags.concat(logged_obj.delete(:tags)) if logged_obj.key?(:tags) tags.uniq! - # Build the event - event = Events.build(logged_obj) - message = event ? event.message : logged_obj[:message] + message = logged_obj.delete(:message) - LogEntry.new(level, time, progname, message, context_snapshot, event, tags: tags) + LogEntry.new(level, time, progname, message, context_snapshot, logged_obj, tags: tags) else LogEntry.new(level, time, progname, logged_obj, context_snapshot, nil, tags: tags) end end @@ -124,16 +121,10 @@ def call(severity, time, progname, msg) build_log_entry(severity, time, progname, msg) end end - # These are rails modules that change the logger behavior. We have to - # include these if they are present or the logger will not function properly - # in a rails environment. - include ::ActiveSupport::LoggerThreadSafeLevel if defined?(::ActiveSupport::LoggerThreadSafeLevel) - include ::LoggerSilence if defined?(::LoggerSilence) - # Creates a new Timber::Logger instance where the passed argument is an IO device. That is, # anything that responds to `#write` and `#close`. # # Note, this method does *not* accept the same arguments as the standard Ruby `::Logger`. # The Ruby `::Logger` accepts additional options controlling file rotation if the first argument @@ -183,11 +174,11 @@ if io_device.is_a?(LogDevices::HTTP) self.formatter = PassThroughFormatter.new elsif Config.instance.development? || Config.instance.test? self.formatter = MessageOnlyFormatter.new else - self.formatter = AugmentedFormatter.new + self.formatter = JSONFormatter.new end self.level = environment_level after_initialize if respond_to?(:after_initialize) @@ -274,6 +265,6 @@ def is_a_logger?(obj) obj.respond_to?(:debug) && obj.respond_to?(:info) && obj.respond_to?(:warn) end end -end \ No newline at end of file +end