diff --git a/packages/helpermodules/data_migration/data_migration.py b/packages/helpermodules/data_migration/data_migration.py index 5d926de8eb..1c53929d9e 100644 --- a/packages/helpermodules/data_migration/data_migration.py +++ b/packages/helpermodules/data_migration/data_migration.py @@ -28,7 +28,7 @@ from helpermodules.utils import thread_handler from helpermodules.pub import Pub -log = logging.getLogger(__name__) +log = logging.getLogger("data_migration") def get_rounding_function_by_digits(digits: Union[int, None]) -> Callable: diff --git a/packages/helpermodules/logger.py b/packages/helpermodules/logger.py index 21874cdc61..5a5d33c4b0 100644 --- a/packages/helpermodules/logger.py +++ b/packages/helpermodules/logger.py @@ -7,6 +7,7 @@ FORMAT_STR_DETAILED = '%(asctime)s - {%(name)s:%(lineno)s} - {%(levelname)s:%(threadName)s} - %(message)s' FORMAT_STR_SHORT = '%(asctime)s - %(message)s' RAMDISK_PATH = str(Path(__file__).resolve().parents[2]) + '/ramdisk/' +PERSISTENT_LOG_PATH = str(Path(__file__).resolve().parents[2]) + '/data/log/' def filter_neg(name: str, record) -> bool: @@ -31,6 +32,13 @@ def mb_to_bytes(megabytes: int) -> int: logging.getLogger().handlers[0].addFilter(functools.partial(filter_neg, "Internal Chargepoint")) logging.getLogger().handlers[0].addFilter(functools.partial(filter_neg, "smarthome")) + data_migration_log = logging.getLogger("data_migration") + data_migration_log.propagate = False + data_migration_file_handler = RotatingFileHandler( + PERSISTENT_LOG_PATH + 'data_migration.log', maxBytes=mb_to_bytes(3), backupCount=1) + data_migration_file_handler.setFormatter(logging.Formatter(FORMAT_STR_SHORT)) + data_migration_log.addHandler(data_migration_file_handler) + mqtt_log = logging.getLogger("mqtt") mqtt_log.propagate = False mqtt_file_handler = RotatingFileHandler(RAMDISK_PATH + 'mqtt.log', maxBytes=mb_to_bytes(3), backupCount=1)