Skip to content

Commit ed09698

Browse files
committed
fix(logging): enhance diagnostic output patterns and anti-patterns in logging standards
1 parent 9c84f66 commit ed09698

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

.github/prompts/dev.implement-logging.prompt.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,28 @@ Audit every Python file in this repository against the logging standards defined
1111
### Step 1: Discover Python files
1212

1313
1. Run `git ls-files '*.py'` to enumerate all tracked Python files.
14-
2. For each file, note whether it imports a logging library (e.g., `logging`, `structlog`, `loguru`) or contains `logger` / `log` references.
14+
2. For each file, search for **any** diagnostic output pattern:
15+
- Logging imports: `logging`, `structlog`, `loguru`, or project logger
16+
- Direct stderr: `sys.stderr.write`, `sys.stderr.flush`
17+
- Print to stderr: `print(..., file=sys.stderr)`
18+
- Print for diagnostics: `print(` used for status/error output
19+
- Logger references: `logger`, `log`, `_log`
20+
3. Flag files with diagnostic output that do **not** import the central logger.
1521

1622
### Step 2: Assess logging practices
1723

1824
For every file that uses logging (or should but does not), evaluate compliance against the categories below. Report each finding and remediate inline where feasible.
1925

2026
## Implementation requirements 🛠️
2127

28+
### Anti-patterns (flag and fix immediately) 🚫
29+
30+
- **Bypassing central logger**: `sys.stderr.write()`, `print(file=sys.stderr)`, or raw `print()` for diagnostic output — route through central logger instead.
31+
- **Direct logging import**: `import logging` / `logging.getLogger()` instead of project factory — use the central logger factory.
32+
- **Inline helper functions**: local `_log_*()` wrappers that write directly to stderr rather than delegating to the central service.
33+
- **Silent failures**: bare `except:` or `except Exception:` without logging.
34+
- **Mixed output channels**: some modules using central logger while others bypass it.
35+
2236
### Principles
2337

2438
- **Signal over noise**: logs must capture intent, boundaries, decisions, and failures—not routine execution. Flag verbose or redundant log statements.
@@ -104,5 +118,5 @@ Flag any misuse (e.g., logging an error condition at INFO).
104118

105119
---
106120

107-
> **Version**: 1.0.1
121+
> **Version**: 1.1.0
108122
> **Last Amended**: 2026-01-28

0 commit comments

Comments
 (0)