]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
fix: restore logging of session start/end
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 2 Jun 2021 19:25:58 +0000 (21:25 +0200)
committerMatthias Hecker <36882671+mattzque@users.noreply.github.com>
Sat, 5 Jun 2021 16:06:45 +0000 (18:06 +0200)
bin/rbot
lib/rbot/ircbot.rb
lib/rbot/logger.rb

index 8c65f42cadaa63f7ec7718392232181762f46e38..cfcb048511052d2791487f245f6eb1ac43b72860 100755 (executable)
--- 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
index 817acd71f537438c267c4860c6b918bbfa43b617..f9f1758ac87ddeb7e0efd6a3034db5b10297ddd1 100644 (file)
@@ -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
index d4717aa68135f8efc4104d2071d87e95a11cf270..4189151c77f9b5a3477f869b3f4e40ca636da091 100644 (file)
@@ -100,6 +100,7 @@ class Bot
         @queue << nil
         @thread.join
         @thread = nil
+        log_session_end
       end
     end