class LoggingElf::TracingLogger
Attributes
trace_hash[W]
Public Class Methods
new(logger, &trace_hash)
click to toggle source
# File lib/logging_elf/tracing_logger.rb, line 28 def initialize(logger, &trace_hash) @logger = Logging::Logger.new logger if logger.is_a? String self.trace_hash = if block_given? trace_hash elsif LoggingElf.config.trace_hash LoggingElf.config.trace_hash else fail "TracingLogger cannot be created with no" \ " mechanism for appending trace data" end end
Public Instance Methods
append_trace_info(data)
click to toggle source
# File lib/logging_elf/tracing_logger.rb, line 68 def append_trace_info(data) data = case data when Hash then data when Exception then exception_data(data) when String then { message: data } when nil then return else default_data(data) end data.merge(trace_hash) end
default_data(data)
click to toggle source
# File lib/logging_elf/tracing_logger.rb, line 61 def default_data(data) { short_message: "Unknown thing to log", message: data.inspect } end
exception_data(data)
click to toggle source
# File lib/logging_elf/tracing_logger.rb, line 51 def exception_data(data) { error_object: data, backtrace: data.backtrace, short_message: "Exception: #{data.message}", message: data.message, is_exception: true } end
trace_hash()
click to toggle source
# File lib/logging_elf/tracing_logger.rb, line 41 def trace_hash hash = if @trace_hash.respond_to?(:call) @trace_hash.call else @trace_hash end hash || {} end