module LogStashLogger::Formatter
Constants
- DEFAULT_FORMATTER
- HOST
Public Class Methods
build_formatter(formatter_type, customize_event)
click to toggle source
# File lib/logstash-logger/formatter.rb, line 17 def self.build_formatter(formatter_type, customize_event) formatter_type ||= DEFAULT_FORMATTER formatter = if custom_formatter_instance?(formatter_type) formatter_type elsif custom_formatter_class?(formatter_type) formatter_type.new else formatter_klass(formatter_type).new(customize_event: customize_event) end formatter.send(:extend, ::LogStashLogger::TaggedLogging::Formatter) formatter end
custom_formatter_class?(formatter_type)
click to toggle source
# File lib/logstash-logger/formatter.rb, line 47 def self.custom_formatter_class?(formatter_type) formatter_type.is_a?(Class) && formatter_type.method_defined?(:call) end
custom_formatter_instance?(formatter_type)
click to toggle source
# File lib/logstash-logger/formatter.rb, line 43 def self.custom_formatter_instance?(formatter_type) formatter_type.respond_to?(:call) end
formatter_klass(formatter_type)
click to toggle source
# File lib/logstash-logger/formatter.rb, line 32 def self.formatter_klass(formatter_type) case formatter_type.to_sym when :json_lines then JsonLines when :json then Json when :logstash_event then LogStashEvent when :cee then Cee when :cee_syslog then CeeSyslog else fail ArgumentError, 'Invalid formatter' end end
new(formatter_type, customize_event: nil)
click to toggle source
# File lib/logstash-logger/formatter.rb, line 13 def self.new(formatter_type, customize_event: nil) build_formatter(formatter_type, customize_event) end