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
A new instance of Entry.
- #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.
Returns a new instance of Entry.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dry/logger/entry.rb', line 47 def initialize(clock:, progname:, severity:, tags: EMPTY_ARRAY, message: nil, payload: EMPTY_HASH) @clock = clock @progname = progname @severity = severity.to_s = @level = LEVELS.fetch(severity.to_s) = 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 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 end |
Instance Method Details
#[](name) ⇒ Object
68 69 70 |
# File 'lib/dry/logger/entry.rb', line 68 def [](name) payload[name] end |
#debug? ⇒ Boolean
74 75 76 |
# File 'lib/dry/logger/entry.rb', line 74 def debug? level.equal?(DEBUG) end |
#each(&block) ⇒ Object
62 63 64 |
# File 'lib/dry/logger/entry.rb', line 62 def each(&block) payload.each(&block) end |
#error? ⇒ Boolean
92 93 94 |
# File 'lib/dry/logger/entry.rb', line 92 def error? level.equal?(ERROR) end |
#exception? ⇒ Boolean
104 105 106 |
# File 'lib/dry/logger/entry.rb', line 104 def exception? !exception.nil? end |
#fatal? ⇒ Boolean
98 99 100 |
# File 'lib/dry/logger/entry.rb', line 98 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.
134 135 136 137 |
# File 'lib/dry/logger/entry.rb', line 134 def filter(filter) @payload = filter.call(payload) self end |
#info? ⇒ Boolean
80 81 82 |
# File 'lib/dry/logger/entry.rb', line 80 def info? level.equal?(INFO) end |
#key?(name) ⇒ Boolean
110 111 112 |
# File 'lib/dry/logger/entry.rb', line 110 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.
122 123 124 |
# File 'lib/dry/logger/entry.rb', line 122 def ||= {progname: progname, severity: severity, time: clock.now} end |
#tag?(value) ⇒ Boolean
116 117 118 |
# File 'lib/dry/logger/entry.rb', line 116 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.
128 129 130 |
# File 'lib/dry/logger/entry.rb', line 128 def to_h @to_h ||= .merge(message: , **payload) end |
#warn? ⇒ Boolean
86 87 88 |
# File 'lib/dry/logger/entry.rb', line 86 def warn? level.equal?(WARN) end |