You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/prompts/dev.implement-logging.prompt.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,13 +33,13 @@ For every file that uses logging (or should but does not), evaluate compliance a
33
33
-**Silent failures**: bare `except:` or `except Exception:` without logging.
34
34
-**Mixed output channels**: some modules using central logger while others bypass it.
35
35
36
-
### Principles
36
+
### Principles 🧭
37
37
38
38
-**Signal over noise**: logs must capture intent, boundaries, decisions, and failures—not routine execution. Flag verbose or redundant log statements.
39
39
-**Structured format**: prefer key=value pairs or JSON; avoid unstructured prose that is hard to parse.
40
40
-**Consistency**: log fields, levels, and phrasing should be uniform across all classes and modules. Flag deviations.
41
41
42
-
### Project-level logger configuration
42
+
### Project-level logger configuration 🏗️
43
43
44
44
-**Single configuration point**: one central factory or module must define logger setup; all other modules import from it.
45
45
-**Environment-driven settings**: log level, sinks, and format must be configurable via environment variables or a config file, not hard-coded.
@@ -49,14 +49,15 @@ For every file that uses logging (or should but does not), evaluate compliance a
49
49
-**No accidental duplication**: require explicit configuration to enable multiple sinks; guard against double logging.
50
50
-**Redaction before output**: sensitive fields must be scrubbed before any sink receives the log entry.
51
51
52
-
### Class-level logging
52
+
### Class-level logging 🧩
53
53
54
+
-**Bound logger pattern (mandatory)**: use the factory function `get_logger(component="ClassName")` which returns a `BoundLogger` pre-bound to the component name. Call log methods directly on the bound logger (`self._logger.debug(...)`) rather than defining per-class wrapper methods (`_log_debug`, `_log_info`, etc.). This eliminates boilerplate and ensures a single point of change.
54
55
-**One logger per class/module**: instantiate a logger with the class or module name so context is always present.
55
56
-**Constructor logging**: log significant configuration or injected dependencies once at INFO when the object is created.
56
57
-**Lifecycle events**: log state transitions (started, stopped, reloaded) at INFO or WARN as appropriate.
57
58
-**Dependency failures**: include identifiers, error details, and retry information when logging external dependency issues.
58
59
59
-
### Method-level logging
60
+
### Method-level logging 🧪
60
61
61
62
-**Entry and exit traces**: every non-trivial method should log entry and exit at DEBUG or TRACE—unless it is a hot path.
62
63
-**Safe input logging**: log inputs only after sanitisation; never log secrets, tokens, or PII.
@@ -65,7 +66,7 @@ For every file that uses logging (or should but does not), evaluate compliance a
65
66
-**Timing information**: log duration for slow or critical operations (or emit metrics instead).
66
67
-**Avoid noise**: do not add "started/finished" logs to trivial or idempotent methods.
0 commit comments