Module: SemanticLogger::Formatters
- Defined in:
- lib/semantic_logger/formatters.rb,
lib/semantic_logger/formatters/raw.rb,
lib/semantic_logger/formatters/base.rb,
lib/semantic_logger/formatters/json.rb,
lib/semantic_logger/formatters/color.rb,
lib/semantic_logger/formatters/logfmt.rb,
lib/semantic_logger/formatters/syslog.rb,
lib/semantic_logger/formatters/default.rb,
lib/semantic_logger/formatters/fluentd.rb,
lib/semantic_logger/formatters/one_line.rb,
lib/semantic_logger/formatters/signalfx.rb,
lib/semantic_logger/formatters/syslog_cee.rb,
lib/semantic_logger/formatters/new_relic_logs.rb
Defined Under Namespace
Classes: Base, Color, Default, Fluentd, Json, Logfmt, NewRelicLogs, OneLine, Raw, Signalfx, Syslog, SyslogCee
Class Method Summary collapse
-
.factory(formatter) ⇒ Object
Return formatter that responds to call.
Class Method Details
.factory(formatter) ⇒ Object
Return formatter that responds to call.
Supports formatter supplied as:
-
Symbol
-
Hash ( Symbol => { options })
-
Instance of any of SemanticLogger::Formatters
-
Proc
-
Any object that responds to :call
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/semantic_logger/formatters.rb', line 24 def self.factory(formatter) if formatter.is_a?(Symbol) SemanticLogger::Utils.constantize_symbol(formatter, "SemanticLogger::Formatters").new elsif formatter.is_a?(Hash) && formatter.size.positive? fmt, = formatter.first SemanticLogger::Utils.constantize_symbol(fmt.to_sym, "SemanticLogger::Formatters").new(**) elsif formatter.respond_to?(:call) formatter else raise(ArgumentError, "Unknown formatter: #{formatter.inspect}") end end |