class Cinch::LoggerList
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.
@attr_writer level @since 2.0.0
Attributes
filters[RW]
A list of log filters that will be applied before emitting a log message.
@return [Array<LogFilter>] @since 2.3.0
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/cinch/logger_list.rb, line 20 def initialize(*args) @filters = [] super end
Public Instance Methods
debug(message)
click to toggle source
(see Logger#debug
)
# File lib/cinch/logger_list.rb, line 37 def debug(message) (m = filter(message, :debug)) && each { |l| l.debug(m) } end
error(message)
click to toggle source
(see Logger#error
)
# File lib/cinch/logger_list.rb, line 42 def error(message) (m = filter(message, :error)) && each { |l| l.error(m) } end
exception(e)
click to toggle source
(see Logger#exception
)
# File lib/cinch/logger_list.rb, line 72 def exception(e) each { |l| l.exception(e) } end
fatal(message)
click to toggle source
(see Logger#error
)
# File lib/cinch/logger_list.rb, line 47 def fatal(message) (m = filter(message, :fatal)) && each { |l| l.fatal(m) } end
incoming(message)
click to toggle source
(see Logger#incoming
)
# File lib/cinch/logger_list.rb, line 62 def incoming(message) (m = filter(message, :incoming)) && each { |l| l.incoming(m) } end
info(message)
click to toggle source
(see Logger#info
)
# File lib/cinch/logger_list.rb, line 52 def info(message) (m = filter(message, :info)) && each { |l| l.info(m) } end
level=(level)
click to toggle source
(see Logger#level=
)
# File lib/cinch/logger_list.rb, line 26 def level=(level) each { |l| l.level = level } end
log(messages, event = :debug, level = event)
click to toggle source
(see Logger#log
)
# File lib/cinch/logger_list.rb, line 31 def log(messages, event = :debug, level = event) messages = Array(messages).map { |m| filter(m, event) }.compact each { |l| l.log(messages, event, level) } end
outgoing(message)
click to toggle source
(see Logger#outgoing
)
# File lib/cinch/logger_list.rb, line 67 def outgoing(message) (m = filter(message, :outgoing)) && each { |l| l.outgoing(m) } end
warn(message)
click to toggle source
(see Logger#warn
)
# File lib/cinch/logger_list.rb, line 57 def warn(message) (m = filter(message, :warn)) && each { |l| l.warn(m) } end
Private Instance Methods
filter(m, ev)
click to toggle source
# File lib/cinch/logger_list.rb, line 78 def filter(m, ev) @filters.each do |f| m = f.filter(m, ev) break if m.nil? end m end