Sha256: 80e91c001a8c4dea1577c907cc9dfa99dae7eaf26006077be5c773d63f5c75b4
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
module SemanticLogger module Formatters # @formatter:off autoload :Base, 'semantic_logger/formatters/base' autoload :Color, 'semantic_logger/formatters/color' autoload :Default, 'semantic_logger/formatters/default' autoload :Json, 'semantic_logger/formatters/json' autoload :Raw, 'semantic_logger/formatters/raw' autoload :OneLine, 'semantic_logger/formatters/one_line' autoload :Signalfx, 'semantic_logger/formatters/signalfx' autoload :Syslog, 'semantic_logger/formatters/syslog' # @formatter:on # 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 def self.factory(formatter) case when formatter.is_a?(Symbol) SemanticLogger::Utils.constantize_symbol(formatter, 'SemanticLogger::Formatters').new when formatter.is_a?(Hash) && formatter.size > 0 fmt, options = formatter.first SemanticLogger::Utils.constantize_symbol(fmt.to_sym, 'SemanticLogger::Formatters').new(options) when formatter.respond_to?(:call) formatter else raise(ArgumentError, "Unknown formatter: #{formatter.inspect}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
semantic_logger-4.2.0 | lib/semantic_logger/formatters.rb |