end
def rawlog(level, message=nil, who_pos=1)
- call_stack = caller
- if call_stack.length > who_pos
- who = call_stack[who_pos].sub(%r{(?:.+)/([^/]+):(\d+)(:in .*)?}) { "#{$1}:#{$2}#{$3}" }
- else
- who = "(unknown)"
- end
- # Output each line. To distinguish between separate messages and multi-line
- # messages originating at the same time, we blank #{who} after the first message
- # is output.
- # Also, we output strings as-is but for other objects we use pretty_inspect
- case message
- when String
- str = message
- else
- str = message.pretty_inspect
+ begin
+ call_stack = caller
+ if call_stack.length > who_pos
+ who = call_stack[who_pos].sub(%r{(?:.+)/([^/]+):(\d+)(:in .*)?}) { "#{$1}:#{$2}#{$3}" }
+ else
+ who = "(unknown)"
+ end
+ # Output each line. To distinguish between separate messages and multi-line
+ # messages originating at the same time, we blank #{who} after the first message
+ # is output.
+ # Also, we output strings as-is but for other objects we use pretty_inspect
+ case message
+ when String
+ str = message
+ else
+ str = message.pretty_inspect
+ end
+ str.each_line { |l|
+ $logger.add(level, l.chomp, who)
+ who.gsub!(/./," ")
+ }
+ rescue SecurityError
end
- str.each_line { |l|
- $logger.add(level, l.chomp, who)
- who.gsub!(/./," ")
- }
end
def log_session_start
@client[:notice] = proc { |data|
message = NoticeMessage.new(self, server, data[:source], data[:target], data[:message])
# pass it off to plugins that want to hear everything
- @plugins.delegate "listen", message
- @plugins.delegate "notice", message
+ @plugins.irc_delegate "notice", message
}
@client[:motd] = proc { |data|
m = MotdMessage.new(self, server, data[:source], data[:target], data[:motd])
debug "Sending quit message"
@socket.emergency_puts "QUIT :#{message}"
debug "Logging quits"
- delegate_sent('QUIT', @bot.myself, message)
+ delegate_sent('QUIT', myself, message)
debug "Flushing socket"
@socket.flush
rescue SocketError => e