Class: Dreamcatcher::LoggerProxy::LogEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/dreamcatcher/logger_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity, prog, message, timestamp = nil) ⇒ LogEntry

Returns a new instance of LogEntry.



51
52
53
54
55
56
# File 'lib/dreamcatcher/logger_proxy.rb', line 51

def initialize(severity, prog, message, timestamp = nil)
  @severity  = severity
  @prog      = prog
  @message   = message
  @timestamp = timestamp || Time.now
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



49
50
51
# File 'lib/dreamcatcher/logger_proxy.rb', line 49

def message
  @message
end

#severityObject (readonly)

Returns the value of attribute severity.



49
50
51
# File 'lib/dreamcatcher/logger_proxy.rb', line 49

def severity
  @severity
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



49
50
51
# File 'lib/dreamcatcher/logger_proxy.rb', line 49

def timestamp
  @timestamp
end

Instance Method Details

#to_s(format = '%t [%s] %m') ⇒ Object



58
59
60
61
62
63
64
# File 'lib/dreamcatcher/logger_proxy.rb', line 58

def to_s(format = '%t [%s] %m')
  format.
    sub('%s', format_severity).
    sub('%m', @message || '').
    sub('%p', @prog || '').
    sub('%t', format_timestamp)
end