From 52e8fdd72b32bb3885ff1970be1f07a4abe84278 Mon Sep 17 00:00:00 2001 From: gdecker1 Date: Sat, 24 Jun 2023 15:32:33 -0700 Subject: [PATCH] rollover logging --- lumaviewpro.py | 5 +++-- lvp_logger.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lumaviewpro.py b/lumaviewpro.py index c4e2123..bf9bfb4 100644 --- a/lumaviewpro.py +++ b/lumaviewpro.py @@ -34,7 +34,7 @@ Gerard Decker, The Earthineering Company MODIFIED: -June 1, 2023 +June 24, 2023 ''' # General @@ -2810,10 +2810,11 @@ def on_start(self): # Clock.schedule_once(lumaview.ids['motionsettings_id'].ids['protocol_settings_id'].ids['stage_widget_id'].draw_labware, 5) def build(self): + current_time = time.strftime("%m/%d/%Y", time.localtime()) logger.info('[LVP Main ] LumaViewProApp.build()') logger.info('[LVP Main ] -----------------------------------------') - logger.info('[LVP Main ] Code Compiled On: 4/20/2023') + logger.info('[LVP Main ] Code Compiled On: %s', current_time) logger.info('[LVP Main ] Run Time: ' + time.strftime("%Y %m %d %H:%M:%S")) logger.info('[LVP Main ] -----------------------------------------') diff --git a/lvp_logger.py b/lvp_logger.py index 22e7fff..d639d8e 100644 --- a/lvp_logger.py +++ b/lvp_logger.py @@ -30,7 +30,7 @@ Gerard Decker, The Earthineering Company MODIFIED: -May 31, 2023 +June 24, 2023 ''' ''' @@ -38,6 +38,7 @@ ''' import logging +from logging.handlers import RotatingFileHandler import os if not os.path.exists("logs/LVP_Log"): os.makedirs("logs/LVP_Log") @@ -67,6 +68,8 @@ def format(self, record): # obtains name of the module (file) importing lvp_logger filename = '%s' % __file__ -file_handler = logging.FileHandler(LOG_FILE) +file_handler = RotatingFileHandler(LOG_FILE, mode='a', maxBytes=1*1024*1024, + backupCount=0, encoding=None, delay=False) +# file_handler = logging.FileHandler(LOG_FILE) file_handler.setFormatter(CustomFormatter()) logger.addHandler(file_handler)