Class: Log4r::DateFileOutputter

### Home Classes Methods

### In Files

- lib/log4r/outputter/datefileoutputter.rb

### Parent

FileOutputter

### 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::DateFileOutputter

Additional hash arguments are:

`:dirname`

  Directory of the log file

`:date_pattern`

  Time.strftime format string (default is "%Y-%m-%d")

### Constants

DEFAULT_DATE_FMT

### Public Class Methods

new(_name, hash={}) click to toggle source

    # File lib/log4r/outputter/datefileoutputter.rb, line 47
    def initialize(_name, hash={})
      @DatePattern = (hash[:date_pattern] or hash['date_pattern'] or
                      DEFAULT_DATE_FMT)
      @DateStamp = Time.now.strftime( @DatePattern);
      _dirname = (hash[:dirname] or hash['dirname'])
      # hash[:dirname] masks hash[:filename]
      if _dirname
        if not FileTest.directory?( _dirname)
          raise StandardError, "'#{_dirname}' must be a valid directory", caller
        end
      end

      _filename = (hash[:filename] or hash['filename'])
      if _filename.nil?
        @filebase = File.basename( $0, '.rb') + ".log"
      else
        @filebase = File.basename((hash[:filename] or hash['filename'] or ""))
      end

      # Get rid of the 'nil' in the path
      path = [_dirname, @filebase.sub(/(\.\w*)$/, "_#{@DateStamp}" + '\1')].compact
      hash[:filename] = hash['filename'] = File.join(path)

      super(_name, hash)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.