Class: Tenderloin::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/tenderloin/util.rb

Constant Summary collapse

@@singleton_logger =
nil
@@level =
Logger::INFO

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_logger!Object



49
50
51
# File 'lib/tenderloin/util.rb', line 49

def reset_logger!
  @@singleton_logger = nil
end

.set_level(level) ⇒ Object



33
34
35
36
# File 'lib/tenderloin/util.rb', line 33

def set_level(level)
  @@singleton_logger.level = level if @@singleton_logger
  @@level = level
end

.singleton_loggerObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/tenderloin/util.rb', line 38

def singleton_logger
  # TODO: Buffer messages until config is loaded, then output them?
  logger = if Tenderloin.config.loaded?
             @@singleton_logger ||= Tenderloin::Logger.new(Tenderloin.config.tenderloin.log_output)
           else
             Tenderloin::Logger.new(nil)
           end
  logger.level = @@level
  logger
end

Instance Method Details

#format_message(level, time, progname, msg) ⇒ Object



54
55
56
# File 'lib/tenderloin/util.rb', line 54

def format_message(level, time, progname, msg)
  "[#{level} #{time.strftime('%m-%d-%Y %X')}] Tenderloin: #{msg}\n"
end