Class: ChronoLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/chrono_logger.rb,
lib/chrono_logger/version.rb

Overview

A lock-free logger with timebased file rotation.

Defined Under Namespace

Modules: Period Classes: TimeBasedLogDevice

Constant Summary collapse

VERSION =
"0.0.4"

Instance Method Summary collapse

Constructor Details

#initialize(logdev) ⇒ ChronoLogger

Returns a new instance of ChronoLogger.

Examples:


ChronoLogger.new('/log/production.log.%Y%m%d')
Time.now.strftime('%F')                       => "2015-01-29"
File.exist?('/log/production.log.20150129')   => true

Parameters:

  • logdev (String, IO)

    `Time#strftime` formatted filename (String) or IO object (typically STDOUT, STDERR, or an open file).


14
15
16
17
18
19
20
21
22
23
# File 'lib/chrono_logger.rb', line 14

def initialize(logdev)
  @progname = nil
  @level = DEBUG
  @default_formatter = Formatter.new
  @formatter = nil
  @logdev = nil
  if logdev
    @logdev = TimeBasedLogDevice.new(logdev)
  end
end