From 810bb69989393fd170350b9b9acbf74ab1dc2488 Mon Sep 17 00:00:00 2001 From: Chris Ballance Date: Thu, 3 Aug 2017 00:31:04 +0100 Subject: [PATCH 1/2] master: rotate logs at midnight, rather than on log size --- RELEASE_NOTES.rst | 1 + artiq/master/log.py | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 0f4327e01..89bc0a463 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -51,6 +51,7 @@ Release notes * The PDQ(2/3) driver has been removed and is now being maintained out-of tree at https://github.com/m-labs/pdq. All SPI/USB driver layers, Mediator, CompoundPDQ and examples/documentation has been moved. +* The master now rotates log files at midnight, rather than based on log size. 2.4 diff --git a/artiq/master/log.py b/artiq/master/log.py index f956dc7e1..581e009b2 100644 --- a/artiq/master/log.py +++ b/artiq/master/log.py @@ -27,11 +27,9 @@ def log_args(parser): group.add_argument("--log-file", default="", help="store logs in rotated files; set the " "base filename") - group.add_argument("--log-max-size", type=int, default=1024, - help="maximum size of each log file in KiB " - "(default: %(default)d)") - group.add_argument("--log-backup-count", type=int, default=6, - help="number of old log files to keep (. is added " + group.add_argument("--log-backup-count", type=int, default=0, + help="number of old log files to keep, or 0 to keep " + "all log files. '.--
' is added " "to the base filename (default: %(default)d)") @@ -47,9 +45,9 @@ def init_log(args): handlers.append(console_handler) if args.log_file: - file_handler = logging.handlers.RotatingFileHandler( + file_handler = logging.handlers.TimedRotatingFileHandler( args.log_file, - maxBytes=args.log_max_size*1024, + when="midnight", backupCount=args.log_backup_count) file_handler.setFormatter(logging.Formatter( "%(asctime)s %(levelname)s:%(source)s:%(name)s:%(message)s")) From eabca1f31104367d139088703f009772db75802b Mon Sep 17 00:00:00 2001 From: Chris Ballance Date: Thu, 3 Aug 2017 10:12:52 +0100 Subject: [PATCH 2/2] master: correct example datestring in help --- artiq/master/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artiq/master/log.py b/artiq/master/log.py index 581e009b2..958076505 100644 --- a/artiq/master/log.py +++ b/artiq/master/log.py @@ -29,7 +29,7 @@ def log_args(parser): "base filename") group.add_argument("--log-backup-count", type=int, default=0, help="number of old log files to keep, or 0 to keep " - "all log files. '.--
' is added " + "all log files. '.--
' is added " "to the base filename (default: %(default)d)")