Class: Yell::Adapters::Datefile

Inherits:
File
  • Object
show all
Defined in:
lib/yell/adapters/datefile.rb

Overview

The Datefile adapter is similar to the File adapter. However, it rotates the file at midnight (by default).

Constant Summary collapse

DefaultDatePattern =

The default date pattern, e.g. “19820114” (14 Jan 1982)

"%Y%m%d"
Header =

Metadata

lambda { |date, pattern| "# -*- #{date.iso8601} (#{date.to_f}) [#{pattern}] -*-" }
HeaderRegexp =
/^# -\*- (.+) \((\d+\.\d+)\) \[(.+)\] -\*-$/

Constants inherited from Io

Io::TTYColors

Instance Attribute Summary collapse

Attributes inherited from Io

#colors, #sync

Method Summary

Methods inherited from Io

#colorize!

Methods included from Helpers::Formatter

#formatter, #formatter=

Methods inherited from Base

close, #close, #initialize, #inspect, open, setup, write, #write

Methods included from Helpers::Level

#level, #level=

Constructor Details

This class inherits a constructor from Yell::Adapters::Base

Instance Attribute Details

#date_patternObject

The pattern to be used for the files

Examples:

date_pattern = "%Y%m%d"       # default
date_pattern = "%Y-week-%V"


22
23
24
# File 'lib/yell/adapters/datefile.rb', line 22

def date_pattern
  @date_pattern
end

#headerObject

You can suppress the first line of the logfile that contains the metadata. This is important upon rollover, because on *nix systems, it is not possible to determine the creation time of a file, on the last access time. The header compensates this.

Examples:

header = false


50
51
52
# File 'lib/yell/adapters/datefile.rb', line 50

def header
  @header
end

#keepObject

Set the amount of logfiles to keep when rolling over. By default, no files will be cleaned up.

Examples:

Keep the last 5 logfiles

keep = 5
keep = '10'

Do not clean up any files

keep = 0


41
42
43
# File 'lib/yell/adapters/datefile.rb', line 41

def keep
  @keep
end

Tell the adapter to create a symlink onto the currently active (timestamped) file. Upon rollover, the symlink is set to the newly created file, and so on.

Examples:

symlink = true


30
31
32
# File 'lib/yell/adapters/datefile.rb', line 30

def symlink
  @symlink
end