Module: Rex::Logging::LogSinkFactory

Defined in:
lib/rex/logging/log_sink_factory.rb

Overview

LogSinkFactory can instantiate a LogSink based on the given name.

Class Method Summary collapse

Class Method Details

.available_sinksArray<Sym>

Returns a list of the available sinks that can be created by this factory

Returns:

  • (Array<Sym>)

    The available sinks that can be created by this factory


32
33
34
# File 'lib/rex/logging/log_sink_factory.rb', line 32

def self.available_sinks
  Rex::Logging::Sinks.constants - [Rex::Logging::Sinks::Stream.name.demodulize.to_sym]
end

.new(name = nil, *attrs) ⇒ Rex::Logging::LogSink

Creates a new log sink of the given name. If no name is provided, a default Flatfile log sink is chosen

Parameters:

  • name (String) (defaults to: nil)

    The name of the required log sink within Rex::Logging::Sinks

  • attrs (Array)

    The attributes to use with the given log sink

Returns:


19
20
21
22
23
24
25
26
27
# File 'lib/rex/logging/log_sink_factory.rb', line 19

def self.new(name = nil, *attrs)
  name ||= Rex::Logging::Sinks::Flatfile.name.demodulize
  raise NameError unless available_sinks.include?(name.to_sym)

  log_sink = Rex::Logging::Sinks.const_get(name)
  log_sink.new(*attrs)
rescue NameError
  raise Rex::ArgumentError, "Could not find logger #{name}, expected one of #{available_sinks.join(', ')}"
end