Skip to content

Commit

Permalink
Remove use of root logger
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreso committed Aug 19, 2024
1 parent ff99bbf commit fd6e8e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/ert/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
ValidationStatus,
)

logger = logging.getLogger(__name__)


def run_ert_storage(args: Namespace, _: Optional[ErtPluginManager] = None) -> None:
with StorageService.start_server(
Expand Down Expand Up @@ -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}"
)

Expand Down
4 changes: 3 additions & 1 deletion src/ert/config/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
QueueSystem,
)

logger = logging.getLogger(__name__)

GENERIC_QUEUE_OPTIONS: List[str] = ["MAX_RUNNING", "SUBMIT_SLEEP"]
LSF_DRIVER_OPTIONS = [
"BHIST_CMD",
Expand Down Expand Up @@ -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}"
)
Expand Down
4 changes: 3 additions & 1 deletion src/ert/gui/tools/export/export_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

from .exporter import Exporter

logger = logging.getLogger(__name__)


class ExportTool(Tool):
def __init__(self, config: ErtConfig, notifier: ErtNotifier):
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/ert/plugins/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from argparse import ArgumentParser
from typing import Any, Callable, Dict, List, Optional, Type

logger = logging.getLogger(__name__)


class WorkflowConfigs:
"""
Expand Down
4 changes: 3 additions & 1 deletion src/ert/simulator/batch_simulator_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit fd6e8e7

Please sign in to comment.