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
-
.available_sinks ⇒ Array<Sym>
Returns a list of the available sinks that can be created by this factory.
-
.new(name = nil, *attrs) ⇒ Rex::Logging::LogSink
Creates a new log sink of the given name.
Class Method Details
.available_sinks ⇒ Array<Sym>
Returns a list of 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
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 |