Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions verifiers/utils/env_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ def load_environment(env_id: str, **env_args) -> Environment:
try:
module = importlib.import_module(module_name)

# Mirror verifiers' configured level onto the env's module logger so
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm not sure we should do this in load_environment - what is the reason for this?

# env code using logging.getLogger(__name__) emits at that level via
# the root JSON handler. Children (e.g. f"{module_name}.scoring")
# inherit. Root stays at default WARNING so third-party libs (httpx,
# httpcore, …) don't spam at DEBUG.
vf_level = logging.getLogger("verifiers").level
if vf_level:
logging.getLogger(module_name).setLevel(vf_level)
Comment on lines +23 to +25
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep env logger level in sync with setup_logging changes

This snapshots verifiers log level at environment load time and permanently assigns it to the env module logger, so later setup_logging(...) calls do not actually reconfigure environment log verbosity. A common sequence like setup_logging("INFO")load_environment(...)setup_logging("DEBUG") will still suppress env DEBUG logs because the module logger remains at INFO. That regresses the expected “multiple calls override config” behavior for already-loaded environments.

Useful? React with 👍 / 👎.


if not hasattr(module, "load_environment"):
raise AttributeError(
f"Module '{module_name}' does not have a 'load_environment' function. "
Expand Down
3 changes: 0 additions & 3 deletions verifiers/utils/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,11 @@ def setup_logging(
# prevent the logger from propagating messages to the root logger
logger.propagate = False

# when json_logging, also configure the root logger so environment code
# using logging.getLogger(__name__) emits JSON too
if json_logging:
root = logging.getLogger()
root.handlers = [
h for h in root.handlers if not isinstance(h.formatter, JsonFormatter)
]
root.setLevel(log_level)
root_handler = logging.StreamHandler(sys.stderr)
root_handler.setFormatter(formatter)
root_handler.setLevel(log_level)
Expand Down
Loading