class TidyLogger

Constants

Error

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/tidy_logger.rb, line 4
def initialize(*args)
  super
  @formatter = Formatter.new
end

Public Instance Methods

config(options = :time_and_level) click to toggle source
# File lib/tidy_logger.rb, line 9
def config(options = :time_and_level)
  case options
  when Symbol
    options = { type: options }
  when Hash
    options[:type] = :time_and_level  if options[:type].nil?
    options[:type] = :title           if options[:title]
  when Proc
    options = { type: options }
  else
    raise Error, "invalid options: #{options.inspect}"
  end

  self.formatter.type             = options[:type]
  self.level                      = options[:level] || Logger::INFO
  self.formatter.datetime_format  = options[:datetime_format] || '%Y-%m-%dT%H:%M:%S'
  self.formatter.title            = options[:title]
  self
end