Module: Participle::Log

Included in:
Bot
Defined in:
lib/logger.rb

Overview

Interface to the participle loggers

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_logger(room)

Add a logger.



108
109
110
111
# File 'lib/logger.rb', line 108

def add_logger(room)
  return false unless @logging
  @queue.add_logger(room)
end

- (Object) error_display(str)

Log an error (exception or whatever).



132
133
134
135
136
137
# File 'lib/logger.rb', line 132

def error_display str
  @queue.error(" \e[1m#{str.class}\e[0m: #{str}")
  str.backtrace.each{|line|
    @queue.error("\t#{line}")
  }
end

- (Object) flush_logs

Finish up logging.



126
127
128
129
# File 'lib/logger.rb', line 126

def flush_logs
  return false unless @logging
  @queue.flush
end

- (Object) log(line, type = "system", username = nil, event = false)

Log line in room. If no room is specified, defaults to "system".



120
121
122
123
# File 'lib/logger.rb', line 120

def log line, type = "system", username = nil, event = false
  return false unless @logging
  @queue.log(event ? "event" : type == "system" ? "system" : "message", line, type, username)
end

- (Object) remove_logger(room)

Remove a logger.



114
115
116
117
# File 'lib/logger.rb', line 114

def remove_logger(room)
  return false unless @logging
  @queue.remove_logger(room)
end

- (Object) setup_logging(*rooms)

Register a logger for each room, and for the bot system logging.



98
99
100
101
102
103
104
105
# File 'lib/logger.rb', line 98

def setup_logging *rooms
  @queue = LogQueue.new(self)
  rooms.flatten.each{|room|
    @queue.add_logger(room)
  }
  @queue.add_logger("system")
  @queue.pretty_display = @pretty
end