From aed5196530434fa5b7f71441293f870d6e75364d Mon Sep 17 00:00:00 2001 From: softwareengineerprogrammer <4056124+softwareengineerprogrammer@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:05:55 -0800 Subject: [PATCH] Use __name__ instead of root for client result & common logger https://github.com/NREL/GEOPHIRES-X/issues/111#issuecomment-1964462981 --- src/geophires_x_client/common.py | 5 ++++- src/geophires_x_client/geophires_x_result.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/geophires_x_client/common.py b/src/geophires_x_client/common.py index 5460cfe8..dbb076ad 100644 --- a/src/geophires_x_client/common.py +++ b/src/geophires_x_client/common.py @@ -4,13 +4,16 @@ _geophires_x_client_logger = None -def _get_logger(logger_name='root'): +def _get_logger(logger_name=None): global _geophires_x_client_logger if _geophires_x_client_logger is None: sh = logging.StreamHandler(sys.stdout) sh.setLevel(logging.INFO) sh.setFormatter(logging.Formatter(fmt='[%(asctime)s][%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')) + if logger_name is None: + logger_name = __name__ + _geophires_x_client_logger = logging.getLogger(logger_name) _geophires_x_client_logger.addHandler(sh) diff --git a/src/geophires_x_client/geophires_x_result.py b/src/geophires_x_client/geophires_x_result.py index 26e9b03a..523f6892 100644 --- a/src/geophires_x_client/geophires_x_result.py +++ b/src/geophires_x_client/geophires_x_result.py @@ -280,7 +280,9 @@ class GeophiresXResult: 'Reservoir Model', ) - def __init__(self, output_file_path, logger_name='root'): + def __init__(self, output_file_path, logger_name=None): + if logger_name is None: + logger_name = __name__ self._logger = _get_logger(logger_name) self.output_file_path = output_file_path