From fd6e8e747d87097d69de8c049927f40864818369 Mon Sep 17 00:00:00 2001 From: Sondre Sortland Date: Mon, 19 Aug 2024 07:56:39 +0200 Subject: [PATCH] Remove use of root logger --- src/ert/__main__.py | 6 ++++-- src/ert/config/queue_config.py | 4 +++- src/ert/gui/tools/export/export_tool.py | 4 +++- src/ert/plugins/workflow_config.py | 2 ++ src/ert/simulator/batch_simulator_context.py | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ert/__main__.py b/src/ert/__main__.py index 92c6d909475..65040fc1b59 100755 --- a/src/ert/__main__.py +++ b/src/ert/__main__.py @@ -42,6 +42,8 @@ ValidationStatus, ) +logger = logging.getLogger(__name__) + def run_ert_storage(args: Namespace, _: Optional[ErtPluginManager] = None) -> None: with StorageService.start_server( @@ -635,9 +637,9 @@ def log_process_usage() -> None: "Swaps": usage.ru_nswap, "Peak memory use (kB)": maxrss, } - logging.info(f"Peak memory use: {maxrss} kB", extra=usage_dict) + logger.info(f"Peak memory use: {maxrss} kB", extra=usage_dict) except Exception as exc: - logging.warning( + logger.warning( f"Exception while trying to log ERT process resource usage: {exc}" ) diff --git a/src/ert/config/queue_config.py b/src/ert/config/queue_config.py index 5ae0e5515d6..1b9d09b7cdb 100644 --- a/src/ert/config/queue_config.py +++ b/src/ert/config/queue_config.py @@ -17,6 +17,8 @@ QueueSystem, ) +logger = logging.getLogger(__name__) + GENERIC_QUEUE_OPTIONS: List[str] = ["MAX_RUNNING", "SUBMIT_SLEEP"] LSF_DRIVER_OPTIONS = [ "BHIST_CMD", @@ -194,7 +196,7 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig: option_name in queue_options[queue_system] and queue_options[queue_system][option_name] != value ): - logging.info( + logger.info( f"Overwriting QUEUE_OPTION {selected_queue_system} {option_name}:" f" \n Old value: {queue_options[queue_system][option_name]} \n New value: {value}" ) diff --git a/src/ert/gui/tools/export/export_tool.py b/src/ert/gui/tools/export/export_tool.py index 790ae8c6131..ee99e04d6f3 100644 --- a/src/ert/gui/tools/export/export_tool.py +++ b/src/ert/gui/tools/export/export_tool.py @@ -15,6 +15,8 @@ from .exporter import Exporter +logger = logging.getLogger(__name__) + class ExportTool(Tool): def __init__(self, config: ErtConfig, notifier: ErtNotifier): @@ -55,7 +57,7 @@ def _run_export(self, params: list[Any]) -> None: QMessageBox.Ok, ) except UserWarning as usrwarning: - logging.error(str(usrwarning)) + logger.error(str(usrwarning)) QMessageBox.warning( cast(QWidget, self.parent()), "Failure", diff --git a/src/ert/plugins/workflow_config.py b/src/ert/plugins/workflow_config.py index be1914e9074..fdb553f6da1 100644 --- a/src/ert/plugins/workflow_config.py +++ b/src/ert/plugins/workflow_config.py @@ -7,6 +7,8 @@ from argparse import ArgumentParser from typing import Any, Callable, Dict, List, Optional, Type +logger = logging.getLogger(__name__) + class WorkflowConfigs: """ diff --git a/src/ert/simulator/batch_simulator_context.py b/src/ert/simulator/batch_simulator_context.py index 5f6f01c8826..136889bee0c 100644 --- a/src/ert/simulator/batch_simulator_context.py +++ b/src/ert/simulator/batch_simulator_context.py @@ -31,6 +31,8 @@ from ert.config import ErtConfig from ert.storage import Ensemble +logger = logging.getLogger(__name__) + Status = namedtuple("Status", "waiting pending running complete failed") @@ -236,7 +238,7 @@ def results(self) -> List[Optional[Dict[str, "npt.NDArray[np.float64]"]]]: res: List[Optional[Dict[str, "npt.NDArray[np.float64]"]]] = [] for sim_id in range(len(self)): if self.get_job_state(iens=sim_id) != JobState.COMPLETED: - logging.error(f"Simulation {sim_id} failed.") + logger.error(f"Simulation {sim_id} failed.") res.append(None) continue d = {}