بنقرة واحدة
logging
Implement structured, secure logging with proper levels, correlation IDs, and redaction
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Implement structured, secure logging with proper levels, correlation IDs, and redaction
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Execute safe Git workflows — branching, committing, resolving conflicts, and managing PRs
Use when controlling AI spend, token budgets, model routing, or workflow efficiency before scaling usage
Use when handling incidents, outages, severe regressions, or operational emergencies before attempting broad fixes
Use when investigating latency, throughput, resource saturation, or performance regressions before changing implementation details
Use when reviewing code, preparing a PR for review, or processing review feedback
Use when diagnosing bugs, test failures, or unexpected behavior before attempting any fix
| name | logging |
| description | Implement structured, secure logging with proper levels, correlation IDs, and redaction |
Implement effective logging — structured format, appropriate levels, correlation IDs, and sensitive data protection.
Use a logging library that supports structured (JSON) output — not console.log.
| Language | Library |
|---|---|
| JavaScript/TS | pino, winston |
| Python | structlog, python-json-logger |
| Go | zerolog, zap |
| Java | SLF4J + Logback |
| Level | When | Example |
|---|---|---|
error | Unexpected failure | Database connection lost |
warn | Concerning but handled | Retry succeeded |
info | Business events | User registered |
debug | Dev details (off in prod) | Function parameters |
Every request should carry a unique ID through all log entries:
// Generate at entry point
const requestId = req.headers['x-request-id'] || uuid()
// Include in all logs
logger.info('Order processed', { requestId, orderId, userId })
Never log: passwords, tokens, API keys, PII, credit card numbers
// BAD
logger.info('Login', { email, password })
// GOOD
logger.info('Login', { email, passwordProvided: !!password })
| Setting | Development | Production |
|---|---|---|
| Level | debug | info |
| Format | Pretty printed | JSON |
| Output | Console | Log aggregator |
| Signal | Action |
|---|---|
| Secrets appearing in logs | Add redaction immediately |
console.log in production code | Replace with structured logger |
| Debug logging enabled in production | Set level to info or higher |
| Error logged AND re-thrown | Choose one — log or throw |
| Skill | When |
|---|---|
| debugging | Using logs to debug issues |
| secure-coding | Ensuring logs don't leak data |