Module: Flare::Util::Logging

Overview

Description

Logging is a mix-in module for logging.

Constant Summary collapse

@@logger =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loggerObject



38
39
40
# File 'lib/flare/util/logging.rb', line 38

def self.logger
  @@logger
end

.set_logger(logger = nil) ⇒ Object



34
35
36
# File 'lib/flare/util/logging.rb', line 34

def self.set_logger(logger = nil)
  @@logger = Logger.new(logger)
end

Instance Method Details

#debug(msg) ⇒ Object



67
68
69
70
# File 'lib/flare/util/logging.rb', line 67

def debug(msg)
  Logging.set_logger if @@logger.nil?
  @@logger.debug(msg)
end

#error(msg) ⇒ Object



57
58
59
60
# File 'lib/flare/util/logging.rb', line 57

def error(msg)
  Logging.set_logger if @@logger.nil?
  @@logger.error(msg)
end

#fatal(msg) ⇒ Object



62
63
64
65
# File 'lib/flare/util/logging.rb', line 62

def fatal(msg)
  Logging.set_logger if @@logger.nil?
  @@logger.fatal(msg)
end

#info(msg) ⇒ Object



42
43
44
45
# File 'lib/flare/util/logging.rb', line 42

def info(msg)
  Logging.set_logger if @@logger.nil?
  @@logger.info(msg)
end

#puts(*args) ⇒ Object

This hides Kernel’s puts()



73
74
75
76
77
78
79
80
# File 'lib/flare/util/logging.rb', line 73

def puts(*args)
  Logging.set_logger if @@logger.nil?
  return Kernel.puts(*args) if @@logger.console?
  for msg in args
    info(msg)
  end
  nil
end

#trace(msg) ⇒ Object



52
53
54
55
# File 'lib/flare/util/logging.rb', line 52

def trace(msg)
  Logging.set_logger if @@logger.nil?
  @@logger.debug(msg)
end

#warn(msg) ⇒ Object



47
48
49
50
# File 'lib/flare/util/logging.rb', line 47

def warn(msg)
  Logging.set_logger if @@logger.nil?
  @@logger.warn(msg)
end