Sha256: 16f63e79a2b5c6fa0aea60345ffb6b22248301f8ace49f397b52834168bd2ff2

Contents?: true

Size: 1023 Bytes

Versions: 25

Compression:

Stored size: 1023 Bytes

Contents

module Lumberjack
  # An entry in a log is a data structure that captures the log message as well as
  # information about the system that logged the message.
  class LogEntry
    attr_accessor :time, :message, :severity, :progname, :pid, :unit_of_work_id
    
    TIME_FORMAT = "%Y-%m-%dT%H:%M:%S".freeze
    
    def initialize(time, severity, message, progname, pid, unit_of_work_id)
      @time = time
      @severity = (severity.is_a?(Fixnum) ? severity : Severity.label_to_level(severity))
      @message = message
      @progname = progname
      @pid = pid
      @unit_of_work_id = unit_of_work_id
    end
    
    def severity_label
      Severity.level_to_label(severity)
    end
    
    def to_s
      buf = "[#{time.strftime(TIME_FORMAT)}.#{(time.usec / 1000.0).round.to_s.rjust(3, '0')} #{severity_label} #{progname}(#{pid})"
      if unit_of_work_id
        buf << " #"
        buf << unit_of_work_id
      end
      buf << "] "
      buf << message
    end
    
    def inspect
      to_s
    end
  end
end

Version data entries

25 entries across 23 versions & 7 rubygems

Version Path
gameboard-3.1.0 vendor/bundle/ruby/2.3.0/gems/lumberjack-1.0.10/lib/lumberjack/log_entry.rb
gameboard-3.0.0 vendor/bundle/ruby/2.3.0/gems/lumberjack-1.0.10/lib/lumberjack/log_entry.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
lumberjack-1.0.10 lib/lumberjack/log_entry.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
geminfo-0.1.0 path/gems/lumberjack-1.0.9/lib/lumberjack/log_entry.rb
lumberjack-1.0.9 lib/lumberjack/log_entry.rb
lumberjack-1.0.8 lib/lumberjack/log_entry.rb
lumberjack-1.0.7 lib/lumberjack/log_entry.rb
lumberjack-1.0.6 lib/lumberjack/log_entry.rb
lumberjack-1.0.5 lib/lumberjack/log_entry.rb
lumberjack_aziz_light-1.0.6 lib/lumberjack/log_entry.rb
lumberjack_aziz_light-1.0.5 lib/lumberjack/log_entry.rb
lumberjack-1.0.4 lib/lumberjack/log_entry.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/lumberjack-1.0.3/lib/lumberjack/log_entry.rb