Class: Dry::Logger::Entry
- Inherits:
-
Object
- Object
- Dry::Logger::Entry
- Includes:
- Enumerable
- Defined in:
- lib/dry/logger/entry.rb
Overview
Instance Attribute Summary collapse
- #clock ⇒ Object readonly private
- #exception ⇒ Object readonly
- #level ⇒ Object readonly
- #message ⇒ Object readonly
- #payload ⇒ Object readonly
- #progname ⇒ Object readonly
- #severity ⇒ Object readonly
- #tags ⇒ Object readonly
Instance Method Summary collapse
- #[](name) ⇒ Object
- #debug? ⇒ Boolean
- #each(&block) ⇒ Object
- #error? ⇒ Boolean
- #exception? ⇒ Boolean
- #fatal? ⇒ Boolean
- #filter(filter) ⇒ Object private
- #info? ⇒ Boolean
-
#initialize(clock:, progname:, severity:, tags: EMPTY_ARRAY, message: nil, payload: EMPTY_HASH) ⇒ Entry
constructor
private
rubocop:disable Metrics/ParameterLists.
- #key?(name) ⇒ Boolean
- #meta ⇒ Object private
- #tag?(value) ⇒ Boolean
- #to_h ⇒ Object private
- #warn? ⇒ Boolean
Constructor Details
#initialize(clock:, progname:, severity:, tags: EMPTY_ARRAY, message: nil, payload: EMPTY_HASH) ⇒ Entry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/ParameterLists
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dry/logger/entry.rb', line 48 def initialize(clock:, progname:, severity:, tags: EMPTY_ARRAY, message: nil, payload: EMPTY_HASH) @clock = clock @progname = progname @severity = severity.to_s @tags = @level = LEVELS.fetch(severity.to_s) @message = unless .is_a?(Exception) @exception = if .is_a?(Exception) @payload = build_payload(payload) end |
Instance Attribute Details
#clock ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/dry/logger/entry.rb', line 43 def clock @clock end |
#exception ⇒ Object (readonly)
35 36 37 |
# File 'lib/dry/logger/entry.rb', line 35 def exception @exception end |
#level ⇒ Object (readonly)
27 28 29 |
# File 'lib/dry/logger/entry.rb', line 27 def level @level end |
#message ⇒ Object (readonly)
31 32 33 |
# File 'lib/dry/logger/entry.rb', line 31 def @message end |
#payload ⇒ Object (readonly)
39 40 41 |
# File 'lib/dry/logger/entry.rb', line 39 def payload @payload end |
#progname ⇒ Object (readonly)
15 16 17 |
# File 'lib/dry/logger/entry.rb', line 15 def progname @progname end |
#severity ⇒ Object (readonly)
19 20 21 |
# File 'lib/dry/logger/entry.rb', line 19 def severity @severity end |
#tags ⇒ Object (readonly)
23 24 25 |
# File 'lib/dry/logger/entry.rb', line 23 def @tags end |
Instance Method Details
#[](name) ⇒ Object
69 70 71 |
# File 'lib/dry/logger/entry.rb', line 69 def [](name) payload[name] end |
#debug? ⇒ Boolean
75 76 77 |
# File 'lib/dry/logger/entry.rb', line 75 def debug? level.equal?(DEBUG) end |
#each(&block) ⇒ Object
63 64 65 |
# File 'lib/dry/logger/entry.rb', line 63 def each(&block) payload.each(&block) end |
#error? ⇒ Boolean
93 94 95 |
# File 'lib/dry/logger/entry.rb', line 93 def error? level.equal?(ERROR) end |
#exception? ⇒ Boolean
105 106 107 |
# File 'lib/dry/logger/entry.rb', line 105 def exception? !exception.nil? end |
#fatal? ⇒ Boolean
99 100 101 |
# File 'lib/dry/logger/entry.rb', line 99 def fatal? level.equal?(FATAL) end |
#filter(filter) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 138 |
# File 'lib/dry/logger/entry.rb', line 135 def filter(filter) @payload = filter.call(payload) self end |
#info? ⇒ Boolean
81 82 83 |
# File 'lib/dry/logger/entry.rb', line 81 def info? level.equal?(INFO) end |
#key?(name) ⇒ Boolean
111 112 113 |
# File 'lib/dry/logger/entry.rb', line 111 def key?(name) payload.key?(name) end |
#meta ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 |
# File 'lib/dry/logger/entry.rb', line 123 def @meta ||= {progname: progname, severity: severity, time: clock.now} end |
#tag?(value) ⇒ Boolean
117 118 119 |
# File 'lib/dry/logger/entry.rb', line 117 def tag?(value) .include?(value) end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
129 130 131 |
# File 'lib/dry/logger/entry.rb', line 129 def to_h @to_h ||= .merge(message: , **payload) end |
#warn? ⇒ Boolean
87 88 89 |
# File 'lib/dry/logger/entry.rb', line 87 def warn? level.equal?(WARN) end |