From ff051b7ae071279b5c2dbddbb5a100c41d7cf349 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Mon, 6 Jan 2020 17:34:11 +0100 Subject: [PATCH] [FIX] runbot: use a logging handler that loves logrotate When the linux logrotate system rename the runbot logfile used by the new builder script, the script continue to write in the reotated file. With this commit, the WatchedFileHandler is used. This handler is specialy crafted to handle this situation, it detects the file renaming and automatically changes to the new file that have the old filename. --- runbot_builder/builder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runbot_builder/builder.py b/runbot_builder/builder.py index 41380b6c..5c397347 100755 --- a/runbot_builder/builder.py +++ b/runbot_builder/builder.py @@ -6,6 +6,8 @@ import sys import threading import signal +from logging.handlers import WatchedFileHandler + LOG_FORMAT = '%(asctime)s %(levelname)s %(name)s: %(message)s' logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) logging.getLogger('odoo.addons.runbot').setLevel(logging.DEBUG) @@ -80,7 +82,7 @@ def run(): if dirname and not os.path.isdir(dirname): os.makedirs(dirname) - handler = logging.FileHandler(args.logfile) + handler = WatchedFileHandler(args.logfile) formatter = logging.Formatter(LOG_FORMAT) handler.setFormatter(formatter) logging.getLogger().addHandler(handler)