From ab23670d711ce0ab3e609421df96d837b6b93350 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 2 Jun 2021 21:25:58 +0200 Subject: fix: restore logging of session start/end --- bin/rbot | 2 ++ lib/rbot/ircbot.rb | 14 +++++++++++--- lib/rbot/logger.rb | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/rbot b/bin/rbot index 8c65f42c..cfcb0485 100755 --- a/bin/rbot +++ b/bin/rbot @@ -123,3 +123,5 @@ if(bot = Irc::Bot.new(ARGV.shift, :argv => orig_opts)) bot.mainloop end +Irc::Bot::LoggerManager.instance.flush +Irc::Bot::LoggerManager.instance.halt_logger diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 817acd71..f9f1758a 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -456,6 +456,8 @@ class Bot end return str.to_s.size end + + LoggerManager.instance.log_session_start end File.open($opts['pidfile'] || File.join(@botclass, 'rbot.pid'), 'w') do |pf| @@ -927,7 +929,8 @@ class Bot # begin event handling loop def mainloop - while true + @keep_looping = true + while @keep_looping too_fast = 0 quit_msg = nil valid_recv = false # did we receive anything (valid) from the server yet? @@ -957,7 +960,8 @@ class Bot # exceptions that ARENT SocketError's. How am I supposed to handle # that? rescue SystemExit - exit 0 + @keep_looping = false + break rescue Errno::ETIMEDOUT, Errno::ECONNABORTED, TimeoutError, SocketError => e error "network exception: #{e.pretty_inspect}" quit_msg = e.to_s @@ -1254,7 +1258,7 @@ class Bot begin shutdown(message) ensure - exit 0 + @keep_looping = false end end @@ -1264,6 +1268,10 @@ class Bot :wait => @config['server.reconnect_wait'] } if (!message || message.empty?) shutdown(message) + + Irc::Bot::LoggerManager.instance.flush + Irc::Bot::LoggerManager.instance.log_session_end + sleep @config['server.reconnect_wait'] begin # now we re-exec diff --git a/lib/rbot/logger.rb b/lib/rbot/logger.rb index d4717aa6..4189151c 100644 --- a/lib/rbot/logger.rb +++ b/lib/rbot/logger.rb @@ -100,6 +100,7 @@ class Bot @queue << nil @thread.join @thread = nil + log_session_end end end -- cgit v1.2.3