Module: Logging

Included in:
Grafana::Client
Defined in:
lib/logging.rb

Overview


Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configure_logger_for(classname) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/logging.rb', line 20

def configure_logger_for( classname )

  logger                 = Logger.new(STDOUT)
  logger.progname        = classname
  logger.level           = Logger::DEBUG
  logger.datetime_format = '%Y-%m-%d %H:%M:%S::%3N'
  logger.formatter       = proc do |severity, datetime, progname, msg|
    "[#{datetime.strftime( logger.datetime_format )}] #{severity.ljust(5)} : #{progname} - #{msg}\n"
  end

  logger
end

.logger_for(classname) ⇒ Object



16
17
18
# File 'lib/logging.rb', line 16

def logger_for( classname )
  @loggers[classname] ||= configure_logger_for( classname )
end

Instance Method Details

#loggerObject



8
9
10
# File 'lib/logging.rb', line 8

def logger
  @logger ||= Logging.logger_for( self.class.name )
end