Class: Cinch::Logger::ZcbotLogger
- Defined in:
- lib/cinch/logger/zcbot_logger.rb
Overview
This logger logs all incoming messages in the format of zcbot. All other debug output (outgoing messages, exceptions, …) will silently be dropped. The sole purpose of this logger is to produce logs parseable by pisg (with the zcbot formatter) to create channel statistics..
Instance Method Summary collapse
-
#debug(messages) ⇒ void
This method can be used by plugins to log custom messages.
-
#initialize(output = STDERR) ⇒ ZcbotLogger
constructor
A new instance of ZcbotLogger.
-
#log(messages, kind = :generic) ⇒ void
This method is used by #debug and #log_exception to log messages, and also by the IRC parser to log incoming and outgoing messages.
-
#log_exception(e) ⇒ void
This method is used for logging messages.
Constructor Details
#initialize(output = STDERR) ⇒ ZcbotLogger
Returns a new instance of ZcbotLogger.
11 12 13 14 |
# File 'lib/cinch/logger/zcbot_logger.rb', line 11 def initialize(output = STDERR) @output = output @mutex = Mutex.new end |
Instance Method Details
#debug(messages) ⇒ void
This method returns an undefined value.
This method can be used by plugins to log custom messages.
17 18 |
# File 'lib/cinch/logger/zcbot_logger.rb', line 17 def debug() end |
#log(messages, kind = :generic) ⇒ void
This method returns an undefined value.
This method is used by #debug and #log_exception to log messages, and also by the IRC parser to log incoming and outgoing messages. You should not have to call this.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cinch/logger/zcbot_logger.rb', line 21 def log(, kind = :generic) return if kind != :incoming @mutex.synchronize do = [].flatten.map {|s| s.to_s.chomp} .each do |msg| @output.puts Time.now.strftime("%m/%d/%Y %H:%M:%S ") + msg.encode("locale", {:invalid => :replace, :undef => :replace}) end end end |
#log_exception(e) ⇒ void
This method returns an undefined value.
This method is used for logging messages.
33 34 |
# File 'lib/cinch/logger/zcbot_logger.rb', line 33 def log_exception(e) end |