Skip to content

log: split streams so levels below WARNING go to stdout #98

Description

@rezib

Summary

rfl.log.setup_logger currently attaches a single logging.StreamHandler() with no stream argument, so all accepted records go to stderr.

For container/CLI usage it is useful to follow the common split:

  • levels below WARNING (DEBUG, INFO) → stdout
  • WARNING and abovestderr

That keeps operational noise off stderr (so tools that treat stderr as “errors only” stay quiet) while preserving WARNING/ERROR/CRITICAL on stderr.

Current behavior

In setup_logger, after resolving the root level and flag filter, RFL does roughly:

handler = logging.StreamHandler()  # defaults to sys.stderr
handler.setLevel(logging_level)
# … formatter + component flag filter …
root_logger.addHandler(handler)

There is no API to choose streams or to split by level.

Proposed behavior

When enabled (exact API TBD), setup_logger would configure two stream handlers sharing the existing formatter and log_flags / debug_flags filter:

Handler stream Records
sys.stdout levelno < logging.WARNING (and still gated by the configured level)
sys.stderr levelno >= logging.WARNING (handler level at least WARNING)

Configured level / debug semantics and component flag filtering should stay unchanged; only the destination stream would change.

Suggested API

Backward-compatible options, e.g.:

  • split_streams: bool = False (default keeps today’s single-stderr behavior), or
  • stream=... plus an optional error_stream=... / threshold

Default should remain current behavior so existing callers are not surprised.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions