mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[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:
parent
926ab4a9d9
commit
ff051b7ae0
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user