Class: Loggun::Modifiers::Sidekiq::LoggunFormatter
- Inherits:
-
Sidekiq::Logger::Formatters::Base
- Object
- Sidekiq::Logger::Formatters::Base
- Loggun::Modifiers::Sidekiq::LoggunFormatter
- Defined in:
- lib/loggun/modifiers/sidekiq/sidekiq4.rb,
lib/loggun/modifiers/sidekiq/sidekiq6.rb
Instance Method Summary collapse
- #call(severity, time, _program_name, message) ⇒ Object
- #prepared_message(message) ⇒ Object
- #split_msg_and_time(message) ⇒ Object
Instance Method Details
#call(severity, time, _program_name, message) ⇒ Object
5 6 7 8 |
# File 'lib/loggun/modifiers/sidekiq/sidekiq4.rb', line 5 def call(severity, time, _program_name, ) , loggun_type = () Loggun::Formatter.new.call(severity, time.utc, nil, , loggun_type: loggun_type) end |
#prepared_message(message) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/loggun/modifiers/sidekiq/sidekiq4.rb', line 10 def () if %w[start].include?() || [/^(done|fail):\s(.*)\ssec$/] , elapsed = split_msg_and_time() loggun_type = "sidekiq.job.#{}" = { tid: "#{Thread.current.object_id.to_s(36)}", context: context.strip } [:elapsed] = elapsed if elapsed else loggun_type = 'app.sidekiq.control' = { tid: Thread.current.object_id.to_s(36), message: } .merge!(context: context) if context end [, loggun_type] end |
#split_msg_and_time(message) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/loggun/modifiers/sidekiq/sidekiq4.rb', line 25 def split_msg_and_time() unless [/^done:\s(.*)\ssec$/] || [/^fail:\s(.*)\ssec$/] return [, nil] end msg_type = [/^done:\s(.*)\ssec$/] ? 'done' : 'fail' msg = [/#{msg_type}:\s(.*)\ssec/] ? msg_type : elapsed = .gsub(/#{msg_type}:\s/, '').gsub('sec', '').strip [msg, elapsed] end |