-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
awCreated by agentic workflowCreated by agentic workflowtest-auditTest coverage gapsTest coverage gaps
Description
Root Cause
src/copilot_usage/logging_config.py contains two callables — setup_logging() and _emoji_patcher() — plus the LEVEL_EMOJI registry. Neither is exercised by any test in the suite. The module is invoked on every CLI run (main() calls setup_logging() before dispatching subcommands), so any regression would silently affect all warning/error output visible to users.
What Is Untested
| Symbol | Behaviour to assert |
|---|---|
setup_logging() |
Removes existing loguru handlers and adds exactly one stderr handler at WARNING level |
setup_logging() |
Is idempotent — calling it twice does not duplicate handlers |
_emoji_patcher |
Injects the correct emoji key into the extra dict for every level in LEVEL_EMOJI |
_emoji_patcher |
Falls back to " " for an unknown level name |
LEVEL_EMOJI |
Contains entries for all standard loguru levels (TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL) |
Expected Behaviour
- After
setup_logging(),loggerhas exactly one sink, it targetssys.stderr, and its minimum level isWARNING. _emoji_patchermutatesrecord["extra"]["emoji"]to match the entry inLEVEL_EMOJI, or" "when the level is not registered.- The
LEVEL_EMOJIdict is a complete mapping covering at least the seven standard loguru levels.
Spec
Add a tests/copilot_usage/test_logging_config.py file with:
# test: setup_logging removes all sinks and adds exactly 1
# test: calling setup_logging() twice still results in exactly 1 sink (idempotency)
# test: after setup_logging(), the single sink targets sys.stderr
# test: after setup_logging(), the minimum log level is "WARNING"
# test: _emoji_patcher sets record["extra"]["emoji"] for each known level
# test: _emoji_patcher falls back to " " for an unknown level name
# test: LEVEL_EMOJI covers TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICALLoguru exposes sink/handler inspection via logger._core.handlers (internal but stable for testing) or by patching sys.stderr and asserting that warnings/errors appear while debug messages do not.
Generated by Test Suite Analysis · ◷
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
awCreated by agentic workflowCreated by agentic workflowtest-auditTest coverage gapsTest coverage gaps