Class: Log4r::PatternFormatter

### Home Classes Methods

### In Files

- lib/log4r/formatter/patternformatter.rb

### Parent

Log4r::BasicFormatter

### Methods

- ::new

### Files

- GDC
- MDC
- NDC
- configurator
- emailoutputter
- formatter
- log4jxmlformatter
- log4r
- logger
- logserver
- outputter
- patternformatter
- scribeoutputter
- syslogoutputter
- win32eventoutputter
- yamlconfigurator

### Class/Module Index

Quicksearch

- Log4r
- Log4r::BasicFormatter
- Log4r::ConfigError
- Log4r::Configurator
- Log4r::DateFileOutputter
- Log4r::DefaultFormatter
- Log4r::EmailOutputter
- Log4r::FileOutputter
- Log4r::Formatter
- Log4r::GDC
- Log4r::IOOutputter
- Log4r::Log4jXmlFormatter
- Log4r::Log4rTools
- Log4r::LogEvent
- Log4r::LogServer
- Log4r::Logger
- Log4r::MDC
- Log4r::NDC
- Log4r::ObjectFormatter
- Log4r::Outputter
- Log4r::PatternFormatter
- Log4r::RemoteOutputter
- Log4r::RollingFileOutputter
- Log4r::RootLogger
- Log4r::ScribeOutputter
- Log4r::SimpleFormatter
- Log4r::StderrOutputter
- Log4r::StdoutOutputter
- Log4r::SyslogOutputter
- Log4r::UDPOutputter
- Log4r::YamlConfigurator
- REXML
- Object

No matching classes.

# Log4r::PatternFormatter

See log4r/formatter/patternformatter.rb

### Constants

DirectiveRegexp

  Matches the first directive encountered and the stuff around it.

  - $1 is the stuff before directive or "" if not applicable

  - $2 is the directive group or nil if there's none

  - $3 is the %#.# match within directive group

  - $4 is the .# match which we don't use (it's there to match properly)

  - $5 is the directive letter

  - $6 is the stuff after the directive or "" if not applicable

  - $7 is the remainder

DirectiveTable

  Arguments to sprintf keyed to directive letters<br> %c - event short name<br> %C - event fullname<br> %d - date<br> %g - Global Diagnostic Context (GDC)<br> %t - trace<br> %m - message<br> %h - thread name<br> %p - process ID aka PID<br> %M - formatted message<br> %l - Level in string form<br> %x - Nested Diagnostic Context (NDC)<br> %X - Mapped Diagnostic Context (MDC), syntax is "%X{key}"<br> %% - Insert a %<br>

ISO8601

  default date format

### Attributes

date_method[R]
date_pattern[R]
pattern[R]

### Public Class Methods

new(hash={}) click to toggle source

Accepts the following hash arguments (either a string or a symbol):

`pattern`

  A pattern format string.

`date_pattern`

  A Time#strftime format string. See the Ruby Time class for details.

`date_method`

  As an option to date_pattern, specify which Time.now method to call. For example, `usec` or `to_s`. Specify it as a String or Symbol.

The default date format is ISO8601, which looks like this:

    yyyy-mm-dd hh:mm:ss    =>    2001-01-12 13:15:50

    # File lib/log4r/formatter/patternformatter.rb, line 79
    def initialize(hash={})
      super(hash)
      @pattern = (hash['pattern'] or hash[:pattern] or nil)
      @date_pattern = (hash['date_pattern'] or hash[:date_pattern] or nil)
      @date_method = (hash['date_method'] or hash[:date_method] or nil)
      @date_pattern = ISO8601 if @date_pattern.nil? and @date_method.nil?
      PatternFormatter.create_format_methods(self)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.