Module: Fig::Logging

Defined in:
lib/fig/logging.rb,
lib/fig/logging/colorizable.rb

Overview

Logging facility that handles the fact that we may wish to do logging prior to Log4r being properly configured.

Defined Under Namespace

Classes: Colorizable

Constant Summary collapse

STRING_TO_LEVEL_MAPPING =
{
  'off'   => Log4r::OFF,
  'fatal' => Log4r::FATAL,
  'error' => Log4r::ERROR,
  'warn'  => Log4r::WARN,
  'info'  => Log4r::INFO,
  'debug' => Log4r::DEBUG,
  'all'   => Log4r::ALL
}
@@logger =
Log4r::Logger.new('initial')

Class Method Summary collapse

Class Method Details

.debug(data = nil, propagated = nil) ⇒ Object



110
111
112
# File 'lib/fig/logging.rb', line 110

def self.debug(data = nil, propagated = nil)
  @@logger.debug data, propagated
end

.debug?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/fig/logging.rb', line 114

def self.debug?()
  return @@logger.debug?
end

.error(data = nil, propagated = nil) ⇒ Object



86
87
88
# File 'lib/fig/logging.rb', line 86

def self.error(data = nil, propagated = nil)
  @@logger.error data, propagated
end

.error?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/fig/logging.rb', line 90

def self.error?()
  return @@logger.error?
end

.fatal(data = nil, propagated = nil) ⇒ Object



78
79
80
# File 'lib/fig/logging.rb', line 78

def self.fatal(data = nil, propagated = nil)
  @@logger.fatal data, propagated
end

.fatal?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/fig/logging.rb', line 82

def self.fatal?()
  return @@logger.fatal?
end

.info(data = nil, propagated = nil) ⇒ Object



102
103
104
# File 'lib/fig/logging.rb', line 102

def self.info(data = nil, propagated = nil)
  @@logger.info data, propagated
end

.info?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/fig/logging.rb', line 106

def self.info?()
  return @@logger.info?
end

.initialize_post_configuration(config_file, log_to_stdout, log_level, suppress_default_configuration = false) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fig/logging.rb', line 37

def self.initialize_post_configuration(
  config_file,
  log_to_stdout,
  log_level,
  suppress_default_configuration = false
)
  if config_file
    begin
      case config_file
        when / [.] xml \z /x
          Log4r::Configurator.load_xml_file(config_file)
        when / [.] ya?ml \z /x
          Log4r::YamlConfigurator.load_yaml_file(config_file)
        else
          raise Fig::ConfigFileError, %Q<Don't know what format #{config_file} is in.>, config_file
      end

      if Log4r::Logger['fig'].nil?
        $stderr.puts %q<A value was provided for --log-config but no "fig" logger was defined.>
      end
    rescue Log4r::ConfigError, ArgumentError => exception
      raise Fig::Log4rConfigError.new(config_file, exception)
    end
  end

  if Log4r::Logger['fig'].nil?
    @@logger = Log4r::Logger.new('fig')
  else
    @@logger = Log4r::Logger['fig']
  end

  if not config_file and not suppress_default_configuration
    assign_log_level(@@logger, 'info')
    setup_default_outputter(@@logger, log_to_stdout)
  end

  assign_log_level(@@logger, log_level)

  return
end

.initialize_pre_configuration(log_to_stdout, log_level) ⇒ Object



30
31
32
33
34
35
# File 'lib/fig/logging.rb', line 30

def self.initialize_pre_configuration(log_to_stdout, log_level)
  log_level ||= 'info'

  assign_log_level(@@logger, log_level)
  setup_default_outputter(@@logger, log_to_stdout)
end

.warn(data = nil, propagated = nil) ⇒ Object



94
95
96
# File 'lib/fig/logging.rb', line 94

def self.warn(data = nil, propagated = nil)
  @@logger.warn data, propagated
end

.warn?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/fig/logging.rb', line 98

def self.warn?()
  return @@logger.warn?
end