Path: blob/master/lib/rex/logging/log_sink_factory.rb
19715 views
# -*- coding: binary -*-123module Rex4module Logging56###7#8# LogSinkFactory can instantiate a LogSink based on the given name.9#10###11module LogSinkFactory12# Creates a new log sink of the given name. If no name is provided, a default13# Flatfile log sink is chosen14#15# @param [String] name The name of the required log sink within Rex::Logging::Sinks16# @param [Array] attrs The attributes to use with the given log sink17# @return [Rex::Logging::LogSink] The newly created log sink18def self.new(name = nil, *attrs)19name ||= Rex::Logging::Sinks::Flatfile.name.demodulize20raise NameError unless available_sinks.include?(name.to_sym)2122log_sink = Rex::Logging::Sinks.const_get(name)23log_sink.new(*attrs)24rescue NameError25raise Rex::ArgumentError, "Could not find logger #{name}, expected one of #{available_sinks.join(', ')}"26end2728# Returns a list of the available sinks that can be created by this factory29#30# @return [Array<Sym>] The available sinks that can be created by this factory31def self.available_sinks32Rex::Logging::Sinks.constants - [Rex::Logging::Sinks::Stream.name.demodulize.to_sym]33end34end35end36end373839