Skip to content

Commit

Permalink
Create one logger object per instantiated Run() object
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Jan 22, 2025
1 parent df39bf4 commit 68543c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions e3sm_diags/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from e3sm_diags.parameter.core_parameter import DEFAULT_SETS, CoreParameter
from e3sm_diags.parser.core_parser import CoreParser

logger = custom_logger(__name__)


class Run:
"""
Expand All @@ -21,6 +19,7 @@ class Run:

def __init__(self):
self.parser = CoreParser()
self.logger = custom_logger(__name__)

# The list of sets to run based on diagnostic parameters.
self.sets_to_run = []
Expand Down Expand Up @@ -76,6 +75,7 @@ def run_diags(
RuntimeError
If a diagnostic run using a parameter fails for any reason.
"""

params = self.get_run_parameters(parameters, use_cfg)
params_results = None

Expand All @@ -88,7 +88,7 @@ def run_diags(
try:
params_results = main(params)
except Exception:
logger.exception("Error traceback:", exc_info=True)
self.logger.exception("Error traceback:", exc_info=True)

# param_results might be None because the run(s) failed, so move
# the log using the `params[0].results_dir` instead.
Expand Down Expand Up @@ -369,7 +369,7 @@ def get_parent(param):
attr_value = getattr(parent, attr)
setattr(parameters[i], attr, attr_value)

logger.info(
self.logger.info(
list(set(nondefault_param_parent) - set(nondefault_param_child))
)
for attr in list(
Expand Down

0 comments on commit 68543c2

Please sign in to comment.