Class: Cinch::LoggerList
- Inherits:
-
Array
- Object
- Array
- Cinch::LoggerList
- Defined in:
- lib/cinch/logger_list.rb
Overview
This class allows Cinch 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) ⇒ void
Logs a debugging message.
-
#error(message) ⇒ void
Logs an error message.
-
#exception(e) ⇒ void
Logs an exception.
-
#fatal(message) ⇒ void
Logs an error message.
-
#incoming(message) ⇒ void
Logs an incoming IRC message.
-
#info(message) ⇒ void
Logs an info message.
-
#initialize(*args) ⇒ LoggerList
constructor
A new instance of LoggerList.
-
#log(messages, event = :debug, level = event) ⇒ void
Logs a message.
-
#outgoing(message) ⇒ void
Logs an outgoing IRC message.
-
#warn(message) ⇒ void
Logs a warning message.
Constructor Details
#initialize(*args) ⇒ LoggerList
Returns a new instance of LoggerList.
20 21 22 23 |
# File 'lib/cinch/logger_list.rb', line 20 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.
19 20 21 |
# File 'lib/cinch/logger_list.rb', line 19 def filters @filters end |
#level=(level) ⇒ Array<:debug, :log, :info, :warn, :error, :fatal> (writeonly)
Returns The minimum level of events to log.
13 14 15 |
# File 'lib/cinch/logger_list.rb', line 13 def level=(value) @level = value end |
Instance Method Details
#debug(message) ⇒ void
This method returns an undefined value.
Logs a debugging message.
37 38 39 |
# File 'lib/cinch/logger_list.rb', line 37 def debug() (m = filter(, :debug)) && each { |l| l.debug(m) } end |
#error(message) ⇒ void
This method returns an undefined value.
Logs an error message.
42 43 44 |
# File 'lib/cinch/logger_list.rb', line 42 def error() (m = filter(, :error)) && each { |l| l.error(m) } end |
#exception(e) ⇒ void
This method returns an undefined value.
Logs an exception.
72 73 74 |
# File 'lib/cinch/logger_list.rb', line 72 def exception(e) each { |l| l.exception(e) } end |
#fatal(message) ⇒ void
This method returns an undefined value.
Logs an error message.
47 48 49 |
# File 'lib/cinch/logger_list.rb', line 47 def fatal() (m = filter(, :fatal)) && each { |l| l.fatal(m) } end |
#incoming(message) ⇒ void
This method returns an undefined value.
Logs an incoming IRC message.
62 63 64 |
# File 'lib/cinch/logger_list.rb', line 62 def incoming() (m = filter(, :incoming)) && each { |l| l.incoming(m) } end |
#info(message) ⇒ void
This method returns an undefined value.
Logs an info message.
52 53 54 |
# File 'lib/cinch/logger_list.rb', line 52 def info() (m = filter(, :info)) && each { |l| l.info(m) } end |
#log(messages, event = :debug, level = event) ⇒ void
This method returns an undefined value.
Logs a message.
31 32 33 34 |
# File 'lib/cinch/logger_list.rb', line 31 def log(, event = :debug, level = event) = Array().map { |m| filter(m, event) }.compact each { |l| l.log(, event, level) } end |
#outgoing(message) ⇒ void
This method returns an undefined value.
Logs an outgoing IRC message.
67 68 69 |
# File 'lib/cinch/logger_list.rb', line 67 def outgoing() (m = filter(, :outgoing)) && each { |l| l.outgoing(m) } end |
#warn(message) ⇒ void
This method returns an undefined value.
Logs a warning message.
57 58 59 |
# File 'lib/cinch/logger_list.rb', line 57 def warn() (m = filter(, :warn)) && each { |l| l.warn(m) } end |