Module: Bellman

Defined in:
lib/bellman/bellman.rb,
lib/bellman/version.rb,
lib/bellman/handlers/sentry.rb,
lib/bellman/handlers/handler.rb,
lib/bellman/handlers/base_handler.rb,
lib/bellman/handlers/rails_logger.rb

Overview

Bellman

Unified way to take all of the log messages and direct them to the right place.

By default all messages will be logged using the Rails standard logger and any message with severity of :error or :fatal will also be sent to Sentry.

For historical details on a bellman/town crier see:

https://en.wikipedia.org/wiki/Town_crier

Defined Under Namespace

Modules: Handlers Classes: Config

Constant Summary collapse

VERSION =
'0.2.2'

Class Method Summary collapse

Class Method Details

.configObject



41
42
43
# File 'lib/bellman/bellman.rb', line 41

def self.config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



45
46
47
48
49
50
51
52
53
54
# File 'lib/bellman/bellman.rb', line 45

def self.configure
  # Set the defaults
  @config = Config.new

  # Yield to block if given
  yield(config) if block_given?

  # Create an instance of the handler that can be used
  @handler = Handlers::Handler.new
end

.handle(error, severity: nil, trace_id: nil, objects: nil, data: nil, include_backtrace: false, handlers: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists



65
66
67
68
69
70
71
72
73
# File 'lib/bellman/bellman.rb', line 65

def self.handle(
  error, severity: nil, trace_id: nil, objects: nil, data: nil,
  include_backtrace: false, handlers: nil
)
  @handler.handle(
    error, severity:, trace_id:, objects:, data:, include_backtrace:,
           handlers:
  )
end

.handler(id: nil) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/bellman/bellman.rb', line 56

def self.handler(id: nil)
  if id.nil?
    @handler
  else
    @handler.handlers.find { |hndlr| hndlr[:id] == id.to_sym }
  end
end