Class: Log4r::Log4rTools

### Home Classes Methods

### In Files

- lib/log4r/base.rb

### Parent

Object

### Methods

- ::comma_split
- ::decode_bool
- ::valid_level?
- ::validate_level

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

Some common functions

### Public Class Methods

comma_split(string) click to toggle source

Splits comma-delimited lists with arbitrary s padding

    # File lib/log4r/base.rb, line 70
    def self.comma_split(string)
      string.split(/\s*,\s*/).collect {|s| s.strip}
    end

decode_bool(hash, symbol, default) click to toggle source

Shortcut for decoding 'true', 'false', true, false or nil into a bool from a hash parameter. E.g., it looks for true/false values for the keys 'symbol' and :symbol.

    # File lib/log4r/base.rb, line 59
    def self.decode_bool(hash, symbol, default)
      data = hash[symbol]
      data = hash[symbol.to_s] if data.nil?
      return case data
        when 'true',true then true
        when 'false',false then false
        else default
        end
    end

valid_level?(lev) click to toggle source

    # File lib/log4r/base.rb, line 45
    def self.valid_level?(lev)
      not lev.nil? and lev.kind_of?(Numeric) and lev >= ALL and lev <= OFF
    end

validate_level(level, depth=0) click to toggle source

Raises ArgumentError if level argument is an invalid level. Depth specifies how many trace entries to remove.

    # File lib/log4r/base.rb, line 38
    def self.validate_level(level, depth=0)
      unless valid_level?(level)
        raise ArgumentError, "Log level must be in 0..#{LEVELS}",
              caller[1..-(depth + 1)]
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.