diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-06-20 11:56:45 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-06-20 11:56:45 +0200 |
commit | be3cd762fbd809c789c3783f866c83b1124f95dd (patch) | |
tree | 03bc8a8cdf6f10258476ea43538ba6113ffd01ee /lib | |
parent | b09833f9d0e01ed655ddec5f73f3a7dd07aafee4 (diff) |
ircbot.rb: ensure that the logger is flushed
If the bot fails to load (e.g. because of missing dependency) the user
might miss the last error messages because the logger thread wouldn't
reach completion. Ensure its closure in an END block.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/ircbot.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 33def8bc..9aef8408 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -66,12 +66,18 @@ def rawlog(level, message=nil, who_pos=1) $log_queue.push qmsg end -def restart_logger(newlogger = false) +def halt_logger if $log_thread && $log_thread.alive? $log_queue << nil $log_thread.join $log_thread = nil end +end + +END { halt_logger } + +def restart_logger(newlogger = false) + halt_logger $logger = newlogger if newlogger |