[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.
This commit is contained in:
Christophe Monniez 2020-01-06 17:34:11 +01:00
parent 926ab4a9d9
commit ff051b7ae0

View File

@ -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)