Class: Roast::Event
- Inherits:
-
Object
- Object
- Roast::Event
- Defined in:
- lib/roast/event.rb
Constant Summary collapse
- LOG_TYPE_KEYS =
[ :fatal, :error, :warn, :info, :debug, :unknown, ].freeze
- OTHER_TYPE_KEYS =
: Array
[ :begin, :end, :stdout, :stderr, :block, ].freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
: Array.
-
#payload ⇒ Object
readonly
: Hash[Symbol, untyped] :payload.
-
#time ⇒ Object
readonly
: Time.
Class Method Summary collapse
-
.<<(event) ⇒ Object
: (Hash[Symbol, untyped]) -> void.
Instance Method Summary collapse
-
#initialize(path, payload) ⇒ Event
constructor
: (Array path, Hash[Symbol, untyped]) -> void.
-
#log_message ⇒ Object
: () -> String.
-
#log_severity ⇒ Object
: () -> Integer.
-
#type ⇒ Object
: () -> Symbol.
Constructor Details
Instance Attribute Details
#payload ⇒ Object (readonly)
: Hash[Symbol, untyped] :payload
34 35 36 |
# File 'lib/roast/event.rb', line 34 def payload @payload end |
#time ⇒ Object (readonly)
: Time
37 38 39 |
# File 'lib/roast/event.rb', line 37 def time @time end |
Class Method Details
.<<(event) ⇒ Object
: (Hash[Symbol, untyped]) -> void
8 9 10 |
# File 'lib/roast/event.rb', line 8 def <<(event) EventMonitor.accept(Event.new(TaskContext.path, event)) end |
Instance Method Details
#log_message ⇒ Object
: () -> String
69 70 71 72 73 74 |
# File 'lib/roast/event.rb', line 69 def key = (LOG_TYPE_KEYS & @payload.keys).first return "" unless key.present? payload[key] || "" end |
#log_severity ⇒ Object
: () -> Integer
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/roast/event.rb', line 56 def log_severity severity = case type when :log (LOG_TYPE_KEYS & @payload.keys).first || :unknown when :stderr :warn else :info end Logger::Severity.const_get(:LEVELS)[severity.to_s] # rubocop:disable Sorbet/ConstantsFromStrings end |
#type ⇒ Object
: () -> Symbol
49 50 51 52 53 |
# File 'lib/roast/event.rb', line 49 def type return :log if (LOG_TYPE_KEYS & @payload.keys).present? (OTHER_TYPE_KEYS & @payload.keys).first || :unknown end |