diff options
author | dmitry kim <jason@nichego.net> | 2008-04-15 23:07:02 +0400 |
---|---|---|
committer | dmitry kim <jason@nichego.net> | 2008-04-15 23:07:02 +0400 |
commit | e86335936a37b372cbdff4b106ba32aff0a0e9dc (patch) | |
tree | 119526b7f483774c57473fc4f473608fc3378161 /lib/rbot/ircbot.rb | |
parent | c3c62ed2f838cdd79a2f26571cbd18642398905c (diff) |
+ ircbot logging: atomic multiline log records
Diffstat (limited to 'lib/rbot/ircbot.rb')
-rw-r--r-- | lib/rbot/ircbot.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 7def98b5..4dcc91fc 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -20,9 +20,9 @@ $logger.level = 0 if $debug $log_queue = Queue.new Thread.new do - l = nil - while l = $log_queue.pop - $logger.add(*l) + ls = nil + while ls = $log_queue.pop + ls.each { |l| $logger.add(*l) } end end @@ -63,10 +63,12 @@ def rawlog(level, message=nil, who_pos=1) else str = message.pretty_inspect end + qmsg = Array.new str.each_line { |l| - $log_queue.push [level, l.chomp, who] + qmsg.push [level, l.chomp, who] who = ' ' * who.size } + $log_queue.push qmsg end def log_session_start |