Class: Lumberjack::MessageAttributes
- Inherits:
-
Object
- Object
- Lumberjack::MessageAttributes
- Defined in:
- lib/lumberjack/message_attributes.rb
Overview
This class can be used as the return value from a formatter call method to extract additional attributes from an object being logged. This can be useful when there using structured logging to include important metadata in the log entry in addition to the message.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(message, attributes) ⇒ MessageAttributes
constructor
A new instance of MessageAttributes.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message, attributes) ⇒ MessageAttributes
Returns a new instance of MessageAttributes.
25 26 27 28 |
# File 'lib/lumberjack/message_attributes.rb', line 25 def initialize(, attributes) = @attributes = attributes || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
21 22 23 |
# File 'lib/lumberjack/message_attributes.rb', line 21 def attributes @attributes end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
21 22 23 |
# File 'lib/lumberjack/message_attributes.rb', line 21 def end |
Instance Method Details
#inspect ⇒ Object
34 35 36 |
# File 'lib/lumberjack/message_attributes.rb', line 34 def inspect {message: , attributes: @attributes}.inspect end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/lumberjack/message_attributes.rb', line 30 def to_s inspect end |