Skip to content

Commit

Permalink
Use silence_log() in report()
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Nov 2, 2023
1 parent 8c58abe commit f196191
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions message_ix_models/report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from message_ix import Reporter, Scenario

from message_ix_models import Context, ScenarioInfo
from message_ix_models.util._logging import mark_time
from message_ix_models.util._logging import mark_time, silence_log

from .config import Config

Expand Down Expand Up @@ -181,7 +181,9 @@ def log_before(context, rep, key) -> None:
log.info(f"Prepare to report {'(DRY RUN)' if context.dry_run else ''}")
log.info(key)
log.log(
logging.INFO if (context.dry_run or context.verbose) else logging.DEBUG,
logging.INFO
if (context.core.dry_run or context.core.verbose)
else logging.DEBUG,
"\n" + rep.describe(key),
)
mark_time()
Expand Down Expand Up @@ -245,7 +247,12 @@ def discard_on_error(*args):
if context.report.legacy["use"]:
return _invoke_legacy_reporting(context)

rep, key = prepare_reporter(context)
with (
nullcontext()
if context.core.verbose
else silence_log(["genno", "message_ix_models"])
):
rep, key = prepare_reporter(context)

log_before(context, rep, key)

Expand Down

0 comments on commit f196191

Please sign in to comment.