Class: GreenLog::Entry
- Inherits:
-
Object
- Object
- GreenLog::Entry
- Defined in:
- lib/green_log/entry.rb
Overview
Represents a structured log entry.
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Class Method Summary collapse
Instance Method Summary collapse
- #in_context(extra_context) ⇒ Object
-
#initialize(severity:, message:, context:, data:, exception:) ⇒ Entry
constructor
A new instance of Entry.
Constructor Details
#initialize(severity:, message:, context:, data:, exception:) ⇒ Entry
Returns a new instance of Entry.
13 14 15 16 17 18 19 |
# File 'lib/green_log/entry.rb', line 13 def initialize(severity:, message:, context:, data:, exception:) @severity = severity @message = @context = context @data = data @exception = exception end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
23 24 25 |
# File 'lib/green_log/entry.rb', line 23 def context @context end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
24 25 26 |
# File 'lib/green_log/entry.rb', line 24 def data @data end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
25 26 27 |
# File 'lib/green_log/entry.rb', line 25 def exception @exception end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
22 23 24 |
# File 'lib/green_log/entry.rb', line 22 def @message end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
21 22 23 |
# File 'lib/green_log/entry.rb', line 21 def severity @severity end |
Class Method Details
.build(severity, *args, &block) ⇒ Object
40 41 42 |
# File 'lib/green_log/entry.rb', line 40 def build(severity, *args, &block) Builder.new(severity).build(*args, &block) end |
.with(**args) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/green_log/entry.rb', line 29 def with(**args) args[:severity] = Severity.resolve( args.fetch(:severity, Severity::INFO), ) args[:message] ||= nil args[:context] = args.fetch(:context, {}).to_loggable_value args[:data] = args.fetch(:data, {}).to_loggable_value args[:exception] ||= nil new(**args) end |