Class: Lumberjack::LogEntry
- Inherits:
-
Object
- Object
- Lumberjack::LogEntry
- Defined in:
- lib/lumberjack/log_entry.rb
Overview
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.
Constant Summary collapse
- TIME_FORMAT =
"%Y-%m-%dT%H:%M:%S".freeze
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#progname ⇒ Object
Returns the value of attribute progname.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#time ⇒ Object
Returns the value of attribute time.
-
#unit_of_work_id ⇒ Object
Returns the value of attribute unit_of_work_id.
Instance Method Summary collapse
-
#initialize(time, severity, message, progname, pid, unit_of_work_id) ⇒ LogEntry
constructor
A new instance of LogEntry.
- #inspect ⇒ Object
- #severity_label ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(time, severity, message, progname, pid, unit_of_work_id) ⇒ LogEntry
Returns a new instance of LogEntry.
9 10 11 12 13 14 15 16 |
# File 'lib/lumberjack/log_entry.rb', line 9 def initialize(time, severity, , progname, pid, unit_of_work_id) @time = time @severity = (severity.is_a?(Fixnum) ? severity : Severity.label_to_level(severity)) @message = @progname = progname @pid = pid @unit_of_work_id = unit_of_work_id end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/lumberjack/log_entry.rb', line 5 def @message end |
#pid ⇒ Object
Returns the value of attribute pid.
5 6 7 |
# File 'lib/lumberjack/log_entry.rb', line 5 def pid @pid end |
#progname ⇒ Object
Returns the value of attribute progname.
5 6 7 |
# File 'lib/lumberjack/log_entry.rb', line 5 def progname @progname end |
#severity ⇒ Object
Returns the value of attribute severity.
5 6 7 |
# File 'lib/lumberjack/log_entry.rb', line 5 def severity @severity end |
#time ⇒ Object
Returns the value of attribute time.
5 6 7 |
# File 'lib/lumberjack/log_entry.rb', line 5 def time @time end |
#unit_of_work_id ⇒ Object
Returns the value of attribute unit_of_work_id.
5 6 7 |
# File 'lib/lumberjack/log_entry.rb', line 5 def unit_of_work_id @unit_of_work_id end |
Instance Method Details
#inspect ⇒ Object
32 33 34 |
# File 'lib/lumberjack/log_entry.rb', line 32 def inspect to_s end |
#severity_label ⇒ Object
18 19 20 |
# File 'lib/lumberjack/log_entry.rb', line 18 def severity_label Severity.level_to_label(severity) end |
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/lumberjack/log_entry.rb', line 22 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 << end |