Sha256: 5042d8355c7a4a0a30f00ad79c9d74a4866600b5d31e426f0458f4a5febadfe7

Contents?: true

Size: 618 Bytes

Versions: 9

Compression:

Stored size: 618 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

9 entries across 9 versions & 1 rubygems

Version Path
logster-2.4.2 lib/examples/sidekiq_logster_reporter.rb
logster-2.4.1 lib/examples/sidekiq_logster_reporter.rb
logster-2.4.0 lib/examples/sidekiq_logster_reporter.rb
logster-2.3.3 lib/examples/sidekiq_logster_reporter.rb
logster-2.3.2 lib/examples/sidekiq_logster_reporter.rb
logster-2.3.1 lib/examples/sidekiq_logster_reporter.rb
logster-2.3.0 lib/examples/sidekiq_logster_reporter.rb
logster-2.2.0 lib/examples/sidekiq_logster_reporter.rb
logster-2.1.1 lib/examples/sidekiq_logster_reporter.rb