GRM-14: feat: use click.echo() for user-facing messages with dual logging
- Create ui.py with say() helper that routes messages to both click.echo()
(console/stdout, user-facing) and logging.getLogger('grm') (file audit trail)
- Update executor.py: replace logger.info() with say() for start, status, done
messages; use say(level=ERROR, err=True) before raising AnsibleError
- Update report.py: replace logger.info() with say() for operation report lines
- Update all unit tests to patch say() instead of using capsys or get_logger
- Add test_ui.py with coverage for say() calling both click.echo and logging
- 117 tests, 100% coverage, pyright clean, ruff clean
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
"""User-facing output utilities for GRM."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
import click
|
||||
|
||||
|
||||
def say(msg: str, level: int = logging.INFO, err: bool = False) -> None:
|
||||
"""Output a message to the user and also log it for auditing.
|
||||
|
||||
Console output goes via ``click.echo`` (handles encoding, CliRunner,
|
||||
Windows colorama). The same message is also sent to the ``grm`` logger
|
||||
so it appears in the persistent log file.
|
||||
"""
|
||||
click.echo(msg, err=err)
|
||||
logging.getLogger("grm").log(level, msg)
|
||||
Reference in New Issue
Block a user