From 24dff868ffa65a3ee0cf48f4575838d990edb7f6 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sun, 24 Nov 2024 19:52:25 -0800 Subject: [PATCH] RotateLogger default is 32 days of logs configure if needed otherwise. --- config.template | 2 ++ logs/README.md | 2 ++ modules/log.py | 4 ++-- modules/settings.py | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config.template b/config.template index 4bfbd55..484efb7 100644 --- a/config.template +++ b/config.template @@ -61,6 +61,8 @@ urlTimeout = 10 LogMessagesToFile = False # Logging of system messages to file SyslogToFile = True +# Number of log files to keep in days, 0 to keep all +log_backup_count = 32 [games] # if hop limit for the user exceeds this value, the message will be dropped diff --git a/logs/README.md b/logs/README.md index 82e0be6..e18eccc 100644 --- a/logs/README.md +++ b/logs/README.md @@ -14,6 +14,8 @@ Logging messages to disk or 'Syslog' to disk uses the python native logging func LogMessagesToFile = False # Logging of system messages to file, needed for reporting engine SyslogToFile = True +# Number of log files to keep in days, 0 to keep all +log_backup_count = 32 ``` To change the stdout (what you see on the console) logging level (default is DEBUG) see the following example, line is in [../modules/log.py](../modules/log.py) diff --git a/modules/log.py b/modules/log.py index 1fc0632..5161abf 100644 --- a/modules/log.py +++ b/modules/log.py @@ -64,7 +64,7 @@ logger.addHandler(stdout_handler) if syslog_to_file: # Create file handler for logging to a file - file_handler_sys = TimedRotatingFileHandler('logs/meshbot{}.log'.format(today.strftime('%Y_%m_%d')), when='midnight', backupCount=32) + file_handler_sys = TimedRotatingFileHandler('logs/meshbot{}.log'.format(today.strftime('%Y_%m_%d')), when='midnight', backupCount=log_backup_count) logging.FileHandler('logs/meshbot{}.log'.format(today.strftime('%Y_%m_%d'))) file_handler_sys.setLevel(logging.DEBUG) # DEBUG used by default for system logs to disk file_handler_sys.setFormatter(plainFormatter(logFormat)) @@ -72,7 +72,7 @@ if syslog_to_file: if log_messages_to_file: # Create file handler for logging to a file - file_handler = TimedRotatingFileHandler('logs/messages{}.log'.format(today.strftime('%Y_%m_%d')), when='midnight', backupCount=32) + file_handler = TimedRotatingFileHandler('logs/messages{}.log'.format(today.strftime('%Y_%m_%d')), when='midnight', backupCount=log_backup_count) file_handler.setLevel(logging.INFO) # INFO used for messages to disk file_handler.setFormatter(logging.Formatter(msgLogFormat)) msgLogger.addHandler(file_handler) \ No newline at end of file diff --git a/modules/settings.py b/modules/settings.py index e720b99..6f57033 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -102,6 +102,7 @@ try: ignoreDefaultChannel = config['general'].getboolean('ignoreDefaultChannel', False) zuluTime = config['general'].getboolean('zuluTime', False) # aka 24 hour time log_messages_to_file = config['general'].getboolean('LogMessagesToFile', False) # default off + log_backup_count = config['general'].getint('LogBackupCount', 32) # default 32 days syslog_to_file = config['general'].getboolean('SyslogToFile', True) # default on urlTimeoutSeconds = config['general'].getint('urlTimeout', 10) # default 10 seconds store_forward_enabled = config['general'].getboolean('StoreForward', True)