Class | Needle::Logger
In: | lib/needle/logger.rb
Parent: | ::Logger

A specialization of the standard Logger class that comes with Ruby. This provides the additional functionality of a fully-customizable message format, whereas the original only provided a customizable date format.

### Methods

message_format= progname= write_to

### Constants

SPECIFIER_OPTIONS

=

{ "c" => { :type => "s", :value => "@name" }, "C" => { :type => "s", :value => "self.progname" }, "d" => { :type => "s", :value => "opts[:timestamp]" }, "F" => { :type => "s", :value => "opts[:caller_file]" }, "l" => { :type => "s", :value => "opts[:caller_info]" }, "L" => { :type => "d", :value => "opts[:caller_line]" }, "m" => { :type => "s", :value => "opts[:msg]" }, "M" => { :type => "s", :value => "opts[:caller_method]" }, "n" => { :type => "s", :value => "$/" }, "p" => { :type => "s", :value => "opts[:severity]" }, "t" => { :type => "d", :value => "Thread.current.__id__" }, "%" => { :type => "s", :value => "'%'" }, "P" => { :type => "s", :value => "opts[:progname]" }, "$" => { :type => "d", :value => "$$" }

The map of specifier options supported by this class.

SPECIFIER_PATTERN | = | /(.*?)%(-?\d*(?:\.\d+)?)?([cCdFlLmMnpt%$P])/ |  | The regular expression for matching specifier patterns in the format strings.

### Attributes

message_format | [R] | The format string for the message (`nil` if the default should be used)
name | [R] | The brief name of this logger (derived from progname).

### Public Instance methods

message_format=( format )

Set the message format string to the given string. This also pre-parses the format for faster processing.

The format string is a printf-formatted string, which supports the following format specifiers:

c: | the unqualified name of the logger
C: | the fully-qualified name of the logger
d: | the date/time string (as formatted by the datetime_format string)
F: | the filename of the calling routine
l: | the location of the calling routine
L: | the line number of the calling routine
m: | the message to log
M: | the name of the calling method
n: | the newline character
p: | the name of the priority (or severity) used to log this method
t: | the id of the current thread
%: | a percentage character
P: | the progname that was passed to the logger method
$: | the current process id

progname=( progname )

Extracts the unqualified name from the progname, after setting the progname.

write_to( device, shift_age = 0, shift_size = 1048576 )

Changes the device that the given logger writes to, to be the given device. Does so in a thread-safe manner.

[Validate]