Class: Log4Ruby::ParameterFormatters

Inherits:
Object
  • Object
show all
Defined in:
lib/log4ruby/formatters/pattern_formatter.rb

Overview

Some common parameter formatters to use with the pattern formatter.

Class Method Summary collapse

Class Method Details

.logger_formatter(index) ⇒ Object

Returns a logger formatter that will format logger objects.

1 would be only the name of the logger, 2 would be the name of the logger’s parent and the name of the logger, and so on…

Parameters:

  • index (Integer)

    an integer that represents how far up the tree the logger’s name should be resolved. So



66
67
68
69
# File 'lib/log4ruby/formatters/pattern_formatter.rb', line 66

def self.logger_formatter(index)
  start =  0 - index
  Proc.new { |logger| logger.full_name.split(".")[start..-1].join(".") }
end

.timestamp_formatter(format_string) ⇒ Object

Returns a timestamp formatter that will format time objects using the specified format string.

Parameters:

  • format_string (String)

    the format string.



74
75
76
# File 'lib/log4ruby/formatters/pattern_formatter.rb', line 74

def self.timestamp_formatter(format_string)
  Proc.new { |timestamp| timestamp.strftime(format_string) }
end