Sha256: 0f0d4034f930735b61ead8a349a55959ac06d50f77dd8775929344cfc02c490e

Contents?: true

Size: 637 Bytes

Versions: 6

Compression:

Stored size: 637 Bytes

Contents

class SidekiqLogsterReporter
  def call(ex, context={})
    # Pass context to Logster
    fake_env = {}
    context.each do |key, value|
      Logster.add_to_env(fake_env, key, value)
    end

    text = "Job exception: #{ex}\n"
    if ex.backtrace
      Logster.add_to_env(fake_env, :backtrace, ex.backtrace)
    end

    Thread.current[Logster::Logger::LOGSTER_ENV] = fake_env
    Logster.logger.error(text)
  rescue => e
    Logster.logger.fatal("Failed to log exception #{ex} #{hash}\nReason: #{e.class} #{e}\n#{e.backtrace.join("\n")}")
  ensure
    Thread.current[Logster::Logger::LOGSTER_ENV] = nil
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logster-1.4.0.pre lib/examples/sidekiq_logster_reporter.rb
logster-1.3.4 lib/examples/sidekiq_logster_reporter.rb
logster-1.3.3 lib/examples/sidekiq_logster_reporter.rb
logster-1.3.2 lib/examples/sidekiq_logster_reporter.rb
logster-1.3.0 lib/examples/sidekiq_logster_reporter.rb
logster-1.3.pre lib/examples/sidekiq_logster_reporter.rb