Class: Cakewalk::LoggerList
- Inherits:
-
Array
- Object
- Array
- Cakewalk::LoggerList
- Defined in:
- lib/cakewalk/logger_list.rb
Overview
This class allows Cakewalk to use multiple loggers at once. A common use-case would be to log formatted messages to STDERR and a pisg-compatible log to a file.
It inherits directly from Array, so adding new loggers is as easy as calling LoggerList#push.
Instance Attribute Summary collapse
-
#filters ⇒ Array<LogFilter>
A list of log filters that will be applied before emitting a log message.
-
#level ⇒ Array<:debug, :log, :info, :warn, :error, :fatal>
writeonly
The minimum level of events to log.
Instance Method Summary collapse
-
#debug(message)
Logs a debugging message.
-
#error(message)
Logs an error message.
-
#exception(e)
Logs an exception.
-
#fatal(message)
Logs an error message.
-
#incoming(message)
Logs an incoming IRC message.
-
#info(message)
Logs an info message.
-
#initialize(*args) ⇒ LoggerList
constructor
A new instance of LoggerList.
-
#log(messages, event = :debug, level = event)
Logs a message.
-
#outgoing(message)
Logs an outgoing IRC message.
-
#warn(message)
Logs a warning message.
Constructor Details
#initialize(*args) ⇒ LoggerList
Returns a new instance of LoggerList.
18 19 20 21 |
# File 'lib/cakewalk/logger_list.rb', line 18 def initialize(*args) @filters = [] super end |
Instance Attribute Details
#filters ⇒ Array<LogFilter>
A list of log filters that will be applied before emitting a log message.
17 18 19 |
# File 'lib/cakewalk/logger_list.rb', line 17 def filters @filters end |
#level=(level) ⇒ Array<:debug, :log, :info, :warn, :error, :fatal> (writeonly)
Returns The minimum level of events to log.
11 12 13 |
# File 'lib/cakewalk/logger_list.rb', line 11 def level=(value) @level = value end |
Instance Method Details
#debug(message)
This method returns an undefined value.
Logs a debugging message.
35 36 37 |
# File 'lib/cakewalk/logger_list.rb', line 35 def debug() (m = filter(, :debug)) && each {|l| l.debug(m)} end |
#error(message)
This method returns an undefined value.
Logs an error message.
40 41 42 |
# File 'lib/cakewalk/logger_list.rb', line 40 def error() (m = filter(, :error)) && each {|l| l.error(m)} end |
#exception(e)
This method returns an undefined value.
Logs an exception.
70 71 72 |
# File 'lib/cakewalk/logger_list.rb', line 70 def exception(e) each {|l| l.exception(e)} end |
#fatal(message)
This method returns an undefined value.
Logs an error message.
45 46 47 |
# File 'lib/cakewalk/logger_list.rb', line 45 def fatal() (m = filter(, :fatal)) && each {|l| l.fatal(m)} end |
#incoming(message)
This method returns an undefined value.
Logs an incoming IRC message.
60 61 62 |
# File 'lib/cakewalk/logger_list.rb', line 60 def incoming() (m = filter(, :incoming)) && each {|l| l.incoming(m)} end |
#info(message)
This method returns an undefined value.
Logs an info message.
50 51 52 |
# File 'lib/cakewalk/logger_list.rb', line 50 def info() (m = filter(, :info)) && each {|l| l.info(m)} end |
#log(messages, event = :debug, level = event)
This method returns an undefined value.
Logs a message.
29 30 31 32 |
# File 'lib/cakewalk/logger_list.rb', line 29 def log(, event = :debug, level = event) = Array().map {|m| filter(m, event)}.compact each {|l| l.log(, event, level)} end |
#outgoing(message)
This method returns an undefined value.
Logs an outgoing IRC message.
65 66 67 |
# File 'lib/cakewalk/logger_list.rb', line 65 def outgoing() (m = filter(, :outgoing)) && each {|l| l.outgoing(m)} end |
#warn(message)
This method returns an undefined value.
Logs a warning message.
55 56 57 |
# File 'lib/cakewalk/logger_list.rb', line 55 def warn() (m = filter(, :warn)) && each {|l| l.warn(m)} end |