Skip to content

Commit

Permalink
Use f-strings in logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Sep 4, 2024
1 parent a96c6f2 commit b6218b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/ert/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def run_cli(args: Namespace, plugin_manager: Optional[ErtPluginManager] = None)
logger = logging.getLogger(__name__)
for fm_step_name, count in counter_fm_steps.items():
logger.info(
"Config contains forward model step %s %d time(s)",
fm_step_name,
count,
f"Config contains forward model step {fm_step_name} {count} time(s)",
)

if not ert_config.observations and args.mode not in [
Expand Down
8 changes: 3 additions & 5 deletions src/ert/config/ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def _log_config_dict(cls, content_dict: Dict[str, Any]) -> None:
tmp_dict.pop("HOOK_WORKFLOW", None)
tmp_dict.pop("WORKFLOW_JOB_DIRECTORY", None)

logger.info("Content of the config_dict: %s", tmp_dict)
logger.info(f"Content of the config_dict: {tmp_dict}")

@staticmethod
def apply_config_content_defaults(content_dict: dict, config_dir: str):
Expand Down Expand Up @@ -633,10 +633,8 @@ def filter_env_dict(self, d):
result[new_key] = new_value
else:
logger.warning(
"Environment variable %s skipped due to"
" unmatched define %s",
new_key,
new_value,
f"Environment variable {new_key} skipped due to"
f" unmatched define {new_value}",
)
# Its expected that empty dicts be replaced with "null"
# in jobs.json
Expand Down
10 changes: 4 additions & 6 deletions src/ert/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _start_initial_gui_window(
and cast(ConfigWarning, w.message).info.is_deprecation
]
error_messages += error.errors
logger.info("Error in config file shown in gui: '%s'", str(error))
logger.info(f"Error in config file shown in gui: '{error}'")
return (
Suggestor(
error_messages,
Expand Down Expand Up @@ -147,18 +147,16 @@ def _start_initial_gui_window(

for fm_step_name, count in counter_fm_steps.items():
logger.info(
"Config contains forward model step %s %d time(s)",
fm_step_name,
count,
f"Config contains forward model step {fm_step_name} {count} time(s)",
)

for wm in all_warnings:
if wm.category != ConfigWarning:
logger.warning(str(wm.message))
for msg in deprecations:
logger.info("Suggestion shown in gui '%s'", msg)
logger.info(f"Suggestion shown in gui '{msg}'")
for msg in config_warnings:
logger.info("Warning shown in gui '%s'", msg)
logger.info(f"Warning shown in gui '{msg}'")
storage = open_storage(ert_config.ens_path, mode="w")
_main_window = _setup_main_window(
ert_config, args, log_handler, storage, plugin_manager
Expand Down

0 comments on commit b6218b5

Please sign in to comment.