lib/timber/log_entry.rb in timber-1.1.0 vs lib/timber/log_entry.rb in timber-1.1.1

- old
+ new

@@ -1,13 +1,13 @@ module Timber # Represents a new log entry into the log. This is an intermediary class between # `Logger` and the log device that you set it up with. class LogEntry #:nodoc: DT_PRECISION = 6.freeze - SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/1.2.3/schema.json".freeze + SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/1.2.4/schema.json".freeze - attr_reader :context_snapshot, :event, :level, :message, :progname, :tags, :time + attr_reader :context_snapshot, :event, :level, :message, :progname, :tags, :time, :time_ms # Creates a log entry suitable to be sent to the Timber API. # @param severity [Integer] the log level / severity # @param time [Time] the exact time the log message was written # @param progname [String] the progname scope for the log message @@ -15,16 +15,17 @@ # @param context_snapshot [Hash] structured data representing a snapshot of the context at # the given point in time. # @param event [Timber.Event] structured data representing the log line event. This should be # an instance of `Timber.Event`. # @return [LogEntry] the resulting LogEntry object - def initialize(level, time, progname, message, context_snapshot, event, tags) + def initialize(level, time, progname, message, context_snapshot, event, options = {}) @level = level @time = time.utc @progname = progname @message = message - @tags = tags + @tags = options[:tags] + @time_ms = options[:time_ms] context_snapshot = {} if context_snapshot.nil? system_context = Contexts::System.new(pid: Process.pid) context_snapshot[system_context.keyspace] = system_context.as_json @@ -32,10 +33,11 @@ @event = event end def as_json(options = {}) options ||= {} - hash = {:level => level, :dt => formatted_dt, :message => message, :tags => tags} + hash = {:level => level, :dt => formatted_dt, :message => message, :tags => tags, + :time_ms => time_ms} if !event.nil? hash[:event] = event end \ No newline at end of file