summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2021-06-02 21:25:58 +0200
committerMatthias Hecker <36882671+mattzque@users.noreply.github.com>2021-06-05 18:06:45 +0200
commitab23670d711ce0ab3e609421df96d837b6b93350 (patch)
treecfb3bab1848b815f429b19e8c60568e27093d5bb
parent03d0839fa48fd9424b7a968986e96b7e69e84d25 (diff)
fix: restore logging of session start/end
-rwxr-xr-xbin/rbot2
-rw-r--r--lib/rbot/ircbot.rb14
-rw-r--r--lib/rbot/logger.rb1
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