Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Use debug level for routine per-operation traces
Don't log every cache/DB read at info; use debug so production logs aren't flooded.
Bad example
| 1 | async getInstrument(insref: number) { |
| 2 | const key = `insref:${insref}`; |
| 3 | logger.info(`getInstrument: fetching key "${key}"`); // runs on every read |
| 4 | return redis.get(key); |
| 5 | } |
Explanation (EN)
An `info` log on every read produces enormous volume in production for a routine, expected operation.
Objašnjenje (HR)
Log na razini `info` pri svakom citanju stvara golem volumen u produkciji za rutinsku, ocekivanu operaciju.
Good example
| 1 | async getInstrument(insref: number) { |
| 2 | const key = `insref:${insref}`; |
| 3 | logger.debug(`getInstrument: fetching key "${key}"`); // off in prod |
| 4 | return redis.get(key); |
| 5 | } |
Explanation (EN)
At `debug`, the trace is available locally and during incident investigation but stays silent under a production `info` threshold.
Objašnjenje (HR)
Na razini `debug` trag je dostupan lokalno i tijekom istrazivanja incidenata, ali ostaje tih ispod produkcijskog praga `info`.
Exceptions / Tradeoffs (EN)
Keep info/warn/error for state changes, failures, and rare events that operators need to see in production.
Iznimke / Tradeoffi (HR)
Zadrzi info/warn/error za promjene stanja, gresjke i rijetke dogadaje koje operateri trebaju vidjeti u produkciji.