Class: Copland::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/copland/logger.rb

Overview

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.

Constant Summary collapse

SPECIFIER_OPTIONS =

The map of specifier options supported by this class.

{
  "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 => "$$" }
}
SPECIFIER_PATTERN =

The regular expression for matching specifier patterns in the format strings.

/(.*?)%(-?\d*(?:\.\d+)?)?([cCdFlLmMnpt%$P])/

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#message_formatObject

The format string for the message (nil if the default should be used)



49
50
51
# File 'lib/copland/logger.rb', line 49

def message_format
  @message_format
end

#nameObject (readonly)

The brief name of this logger (derived from #progname).



46
47
48
# File 'lib/copland/logger.rb', line 46

def name
  @name
end

Instance Method Details

#progname=(progname) ⇒ Object

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



75
76
77
78
# File 'lib/copland/logger.rb', line 75

def progname=( progname )
  super
  @name = progname.split( /\./ ).last
end