module Fuli

Constants

Error
VERSION

Attributes

config[W]

Public Class Methods

configure() { |config = instance| ... } click to toggle source
# File lib/fuli.rb, line 55
def configure
  yield @config = Fuli::Config.instance if block_given?
  raise Fuli::Error, 'logger is a mandatory configuration' unless @config.logger
end
log(message_or_error, level: :info) { || ... } click to toggle source
# File lib/fuli.rb, line 50
def log(message_or_error, level: :info)
  yield if block_given?
  logger.public_send(level, message_or_error)
end
notify_error(error, context_message = nil) click to toggle source

Logs error level and calls error notifiers.

Example:

class Cheetah
  def hunt
    # do things
  rescue => e
    Fuli.notify_error(e, key: :value)
  end
end

Arguments:

object: Object that responds to to_s method
object: Object that responds to inspect method
# File lib/fuli.rb, line 44
def notify_error(error, context_message = nil)
  log(error, level: :error) do
    @config.error_notifiers&.map { |notifier| notifier.call(error, context_message) }
  end
end
notify_warning(error, context_message = nil) click to toggle source

Logs warn level and calls warn notifiers.

Example:

class Cheetah
  def hunt
    # do things
  rescue => e
    Fuli.notify_warning(e, key: :value)
  end
end

Arguments:

object: Object that responds to to_s method
object: Object that responds to inspect method
# File lib/fuli.rb, line 25
def notify_warning(error, context_message = nil)
  log(error, level: :warn) do
    @config.warn_notifiers&.map { |notifier| notifier.call(error, context_message) }
  end
end

Private Class Methods

logger() click to toggle source
# File lib/fuli.rb, line 62
def logger
  @config.logger
end