Module: Logging::Appenders

Extended by:
Appenders
Included in:
Appenders
Defined in:
lib/logging/appenders.rb,
lib/logging/appenders/io.rb,
lib/logging/appenders/file.rb,
lib/logging/appenders/syslog.rb,
lib/logging/appenders/console.rb,
lib/logging/appenders/buffering.rb,
lib/logging/appenders/string_io.rb,
lib/logging/appenders/rolling_file.rb

Defined Under Namespace

Modules: Buffering Classes: Console, File, IO, RollingFile, StringIo, Syslog

Constant Summary collapse

Stdout =

This class provides an Appender that can write to STDOUT.

Class.new(Console)
Stderr =

This class provides an Appender that can write to STDERR.

Class.new(Console)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.file(*args) ⇒ Object

Accessor / Factory for the File appender.


5
6
7
8
# File 'lib/logging/appenders/file.rb', line 5

def self.file( *args )
  fail ArgumentError, '::Logging::Appenders::File needs a name as first argument.' if args.empty?
  ::Logging::Appenders::File.new(*args)
end

.io(*args) ⇒ Object

Accessor / Factory for the IO appender.


5
6
7
8
# File 'lib/logging/appenders/io.rb', line 5

def self.io( *args )
  return ::Logging::Appenders::IO if args.empty?
  ::Logging::Appenders::IO.new(*args)
end

.rolling_file(*args) ⇒ Object

Accessor / Factory for the RollingFile appender.


4
5
6
7
# File 'lib/logging/appenders/rolling_file.rb', line 4

def self.rolling_file( *args )
  fail ArgumentError, '::Logging::Appenders::RollingFile needs a name as first argument.' if args.empty?
  ::Logging::Appenders::RollingFile.new(*args)
end

.stderr(*args) ⇒ Object

Accessor / Factory for the Stderr appender.


76
77
78
79
80
81
# File 'lib/logging/appenders/console.rb', line 76

def self.stderr( *args )
  if args.empty?
    return self['stderr'] || ::Logging::Appenders::Stderr.new
  end
  ::Logging::Appenders::Stderr.new(*args)
end

.stdout(*args) ⇒ Object

Accessor / Factory for the Stdout appender.


68
69
70
71
72
73
# File 'lib/logging/appenders/console.rb', line 68

def self.stdout( *args )
  if args.empty?
    return self['stdout'] || ::Logging::Appenders::Stdout.new
  end
  ::Logging::Appenders::Stdout.new(*args)
end

.string_io(*args) ⇒ Object

Accessor / Factory for the StringIo appender.


6
7
8
9
# File 'lib/logging/appenders/string_io.rb', line 6

def self.string_io( *args )
  return ::Logging::Appenders::StringIo if args.empty?
  ::Logging::Appenders::StringIo.new(*args)
end

.syslog(*args) ⇒ Object

Accessor / Factory for the Syslog appender.


11
12
13
14
# File 'lib/logging/appenders/syslog.rb', line 11

def self.syslog( *args )
  fail ArgumentError, '::Logging::Appenders::Syslog needs a name as first argument.' if args.empty?
  ::Logging::Appenders::Syslog.new(*args)
end

Instance Method Details

#[](name) ⇒ Object

call-seq:

Appenders[name]

Returns the appender instance stored in the appender hash under the key name, or nil if no appender has been created using that name.


11
# File 'lib/logging/appenders.rb', line 11

def []( name ) @appenders[name] end

#[]=(name, value) ⇒ Object

call-seq:

Appenders[name] = appender

Stores the given appender instance in the appender hash under the key name.


19
# File 'lib/logging/appenders.rb', line 19

def []=( name, value ) @appenders[name] = value end

#each(&block) ⇒ Object

call-seq:

each {|appender| block}

Yield each appender to the block.


34
35
36
37
# File 'lib/logging/appenders.rb', line 34

def each( &block )
  @appenders.values.each(&block)
  return nil
end

#remove(name) ⇒ Object

call-seq:

Appenders.remove( name )

Removes the appender instance stored in the appender hash under the key name.


27
# File 'lib/logging/appenders.rb', line 27

def remove( name ) @appenders.delete(name) end

#resetObject

:stopdoc:


40
41
42
43
44
45
46
47
# File 'lib/logging/appenders.rb', line 40

def reset
  @appenders.values.each {|appender|
    next if appender.nil?
    appender.close
  }
  @appenders.clear
  return nil
end