Module: Better::Logger

Defined in:
lib/better-logger/base.rb,
lib/better-logger/config.rb,
lib/better-logger/logger.rb,
lib/better-logger/loggers.rb,
lib/better-logger/version.rb

Defined Under Namespace

Modules: Loggers Classes: Config, Logger

Constant Summary collapse

LEVELS =
{
  debug:  0,
  info:   1,
  warn:   2,
  error:  3,
  fatal:  4,
  silent: 100,
}
VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.config(log_name = :log) {|conf_object| ... } ⇒ Object

Yields:

  • (conf_object)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/better-logger/base.rb', line 12

def self.config log_name = :log, &block
  conf_object = Config.new
  yield conf_object

  # The "Loggers" module gets included into the main namespace when
  # better-logger is required. By defining a method in it, we define a
  # method in the main namespace. This allows the loggers to be accessed
  # from anywhere.
  Loggers._log_hash[log_name] = Logger.new(conf_object)
  Loggers.send :define_method, log_name do
    Loggers._log_hash[log_name]
  end
end