Skip to content

Instantly share code, notes, and snippets.

@simonoff
Created February 3, 2022 13:00
Show Gist options
  • Save simonoff/24e1d5fa495fec2e4de863903bbf7f46 to your computer and use it in GitHub Desktop.
Save simonoff/24e1d5fa495fec2e4de863903bbf7f46 to your computer and use it in GitHub Desktop.
class Sidekiq::Logger::Formatters::Jsoner < Sidekiq::Logger::Formatters::Base
def call(severity, time, program_name, message)
hash = {
application: "prog-sidekiq",
time: time.utc.to_i,
level: severity,
tid: tid,
message: message
}
c = ctx
hash["ctx"] = c unless c.empty?
::JSON.generate(hash) + "\n"
end
end
Sidekiq.log_formatter = Sidekiq::Logger::Formatters::Jsoner.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment