Class: Filum::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/filum/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logfile, options = {}) ⇒ Logger

Returns a new instance of Logger.



9
10
11
12
13
14
15
16
17
# File 'lib/filum/logger.rb', line 9

def initialize(logfile, options = {})
  @timings = {}
  @logfile = logfile
  create_log_directory

  super(logfile, shift_age='daily')
  self.formatter = Filum::LogFormatter.new(options)
  self.level = Logger::INFO
end

Instance Attribute Details

#logfileObject (readonly)

Returns the value of attribute logfile.



7
8
9
# File 'lib/filum/logger.rb', line 7

def logfile
  @logfile
end

Instance Method Details

#context_id=(context_id) ⇒ Object



19
20
21
# File 'lib/filum/logger.rb', line 19

def context_id=(context_id)
  Thread.current[:context_id] = context_id
end

#end_timing(label) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/filum/logger.rb', line 28

def end_timing(label)
  finish = Time.now
  if @timings[label]
    info("Stopped timing for #{label} at #{@timings[label]}, #{(finish.to_f - @timings[label].to_f).round(3)}")
    @timings.delete(label)
  else
    info("Stopped timing for #{label} at #{@timings[label]}, no start time found")
  end
end

#start_timing(label) ⇒ Object



23
24
25
26
# File 'lib/filum/logger.rb', line 23

def start_timing(label)
  @timings[label] = Time.now
  info("Started timing for #{label} at #{@timings[label]}")
end