Class: ExceptionNotifier::FluentLoggerNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_notifier/fluent_logger_notifier.rb,
lib/exception_notifier/fluent_logger_notifier/version.rb

Defined Under Namespace

Classes: Argument, ConfigurationError, SetupError

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FluentLoggerNotifier

Returns a new instance of FluentLoggerNotifier.

Raises:



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/exception_notifier/fluent_logger_notifier.rb', line 8

def initialize(options)
  @template = options.delete(:template)
  raise ConfigurationError, "`template` key must be set" unless @template

  logger_settings = options.delete(:logger_settings) || {}
  if options.delete(:test_logger)
    @logger = Fluent::Logger::TestLogger.new
  else
    tag_prefix = options.delete(:tag_prefix)
    @logger = Fluent::Logger::FluentLogger.new(tag_prefix, logger_settings)
  end
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/exception_notifier/fluent_logger_notifier.rb', line 5

def logger
  @logger
end

#templateObject

Returns the value of attribute template.



5
6
7
# File 'lib/exception_notifier/fluent_logger_notifier.rb', line 5

def template
  @template
end

Instance Method Details

#call(exception, options = {}) ⇒ Object



21
22
23
24
# File 'lib/exception_notifier/fluent_logger_notifier.rb', line 21

def call(exception, options={})
  arg = Argument.build(template, exception, options)
  logger.post(nil, arg)
end