Class: Istox::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/istox/helpers/logger.rb

Class Method Summary collapse

Class Method Details

.loggerObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/istox/helpers/logger.rb', line 5

def self.logger
  return @logger if @logger.present?

  @logger = ::Ougai::Logger.new(STDOUT)
  @logger.formatter = ::Ougai::Formatters::Readable.new unless ENV.fetch('RAILS_ENV','development') == 'production'|| (defined?(Rails) && Rails.env.production?)

  # adding thread id to logger
  @logger.before_log = lambda do |data|
    data[:tracer_id] = Thread.current[:tracer_id]
    data[:thread_id] = Thread.current.object_id
  end

  @logger
end