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 18 def initialize(*args) @filters = [] super end
Public Instance Methods
debug(message)
click to toggle source
(see Cinch::Logger#debug)
# File lib/cinch/logger_list.rb, line 35 def debug(message) (m = filter(message, :debug)) && each {|l| l.debug(m)} end
error(message)
click to toggle source
(see Cinch::Logger#error)
# File lib/cinch/logger_list.rb, line 40 def error(message) (m = filter(message, :error)) && each {|l| l.error(m)} end
exception(e)
click to toggle source
(see Cinch::Logger#exception)
# File lib/cinch/logger_list.rb, line 70 def exception(e) each {|l| l.exception(e)} end
fatal(message)
click to toggle source
(see Cinch::Logger#error)
# File lib/cinch/logger_list.rb, line 45 def fatal(message) (m = filter(message, :fatal)) && each {|l| l.fatal(m)} end
incoming(message)
click to toggle source
(see Cinch::Logger#incoming)
# File lib/cinch/logger_list.rb, line 60 def incoming(message) (m = filter(message, :incoming)) && each {|l| l.incoming(m)} end
info(message)
click to toggle source
(see Cinch::Logger#info)
# File lib/cinch/logger_list.rb, line 50 def info(message) (m = filter(message, :info)) && each {|l| l.info(m)} end
level=(level)
click to toggle source
(see Cinch::Logger#level)
# File lib/cinch/logger_list.rb, line 24 def level=(level) each {|l| l.level = level} end
log(messages, event = :debug, level = event)
click to toggle source
(see Cinch::Logger#log)
# File lib/cinch/logger_list.rb, line 29 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 Cinch::Logger#outgoing)
# File lib/cinch/logger_list.rb, line 65 def outgoing(message) (m = filter(message, :outgoing)) && each {|l| l.outgoing(m)} end
warn(message)
click to toggle source
(see Cinch::Logger#warn)
# File lib/cinch/logger_list.rb, line 55 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 75 def filter(m, ev) @filters.each do |f| m = f.filter(m, ev) if m.nil? break end end m end