Class: Sherlog::Entry
- Inherits:
-
Object
- Object
- Sherlog::Entry
- Defined in:
- lib/sherlog_holmes/entry.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#exceptions ⇒ Object
Returns the value of attribute exceptions.
-
#level ⇒ Object
Returns the value of attribute level.
-
#message ⇒ Object
Returns the value of attribute message.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#raw_content ⇒ Object
Returns the value of attribute raw_content.
-
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #<<(line) ⇒ Object
- #[](custom_attribute) ⇒ Object
- #exception ⇒ Object
- #exception? ⇒ Boolean
-
#initialize(params = {}) ⇒ Entry
constructor
A new instance of Entry.
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Entry
Returns a new instance of Entry.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sherlog_holmes/entry.rb', line 28 def initialize(params = {}) params = params.dup @time = params.delete :time if params[:time] @level = params.delete :level if params[:level] @category = params.delete :category if params[:category] @origin = params.delete :origin if params[:origin] @message = params.delete :message if params[:message] @raw_content = params.delete :raw_content if params[:raw_content] @exceptions = [params.delete(:exception)] if params[:exception] @exceptions ||= params.delete(:exceptions) if params[:exceptions] @exceptions ||= [] @stacktrace = [] @custom_attributes = params end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def category @category end |
#exceptions ⇒ Object
Returns the value of attribute exceptions.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def exceptions @exceptions end |
#level ⇒ Object
Returns the value of attribute level.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def level @level end |
#message ⇒ Object
Returns the value of attribute message.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def @message end |
#origin ⇒ Object
Returns the value of attribute origin.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def origin @origin end |
#raw_content ⇒ Object
Returns the value of attribute raw_content.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def raw_content @raw_content end |
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def stacktrace @stacktrace end |
#time ⇒ Object
Returns the value of attribute time.
26 27 28 |
# File 'lib/sherlog_holmes/entry.rb', line 26 def time @time end |
Instance Method Details
#<<(line) ⇒ Object
51 52 53 |
# File 'lib/sherlog_holmes/entry.rb', line 51 def <<(line) @message << $/ << line end |
#[](custom_attribute) ⇒ Object
55 56 57 |
# File 'lib/sherlog_holmes/entry.rb', line 55 def [](custom_attribute) @custom_attributes[custom_attribute.to_s] or @custom_attributes[custom_attribute.to_sym] end |
#exception ⇒ Object
47 48 49 |
# File 'lib/sherlog_holmes/entry.rb', line 47 def exception @exceptions.first end |
#exception? ⇒ Boolean
43 44 45 |
# File 'lib/sherlog_holmes/entry.rb', line 43 def exception? !@exceptions.empty? end |
#to_s ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/sherlog_holmes/entry.rb', line 59 def to_s format = [] params = [] format << '%s' && params << time if time format << '%s' && params << level.to_s.ljust(7) if level format << '[%s]' && params << category if category format << '(%s)' && params << origin if origin format << '%s' && params << if string = format.join(' ') % params ([string] + @stacktrace).join($/) end |