singularity-forge/src/resources/skills/code-optimizer/references/logging-observability.md
Juan Francisco Lebrero 7868761ca0 feat: add 10 bundled skills for UI, quality, and code optimization (#999)
Add community-sourced skills covering:

Coding & Quality:
- code-optimizer: 13-domain parallel optimization audit
- react-best-practices: 57 React/Next.js performance rules (Vercel)
- best-practices: Web security, CSP, HTTPS, HTML validity

UI & Design:
- userinterface-wiki: 152 UI/UX rules (animations, springs, UX laws, typography)
- make-interfaces-feel-better: 16 practical polish principles

Testing & Audit:
- web-quality-audit: Lighthouse-style 150+ checks
- accessibility: WCAG guidelines and ARIA patterns
- core-web-vitals: LCP/CLS/INP deep dive
- web-design-guidelines: Vercel Web Interface Guidelines

Tooling:
- agent-browser: Browser automation CLI for testing and scraping
2026-03-17 17:23:39 -06:00

2.6 KiB

Logging & Observability Performance

Grep/Glob Patterns to Detect

Excessive Logging

console\.log\(                     (console.log in production code)
console\.debug\(                   (console.debug in production)
print\(.*debug                     (Python print debugging)
logger\.debug\(.*inside.*loop      (debug logging in hot loop)
log\.\w+\(.*inside.*for            (any logging in tight loop)
console\.log\(JSON\.stringify\(    (serializing objects just to log)

Expensive String Formatting in Logs

# String interpolation/formatting when log level is disabled
logger\.debug\(f"                  (Python f-string even when debug disabled)
logger\.debug\(.*\.format\(        (Python .format() even when debug disabled)
logger\.debug\(`                   (JS template literal even when debug disabled)
logger\.debug\(.*\+.*\+            (string concat for debug log)
JSON\.stringify\(.*log             (JSON stringify for logging)

Missing Structured Logging

console\.log\(["'].*:.*["']        (unstructured string logging)
print\(.*["'].*:.*["']             (unstructured print logging)
logger\.\w+\(["'].*["'] %         (format string logging vs structured)

Synchronous Logging

fs\.writeFileSync.*log             (sync file write for logging)
fs\.appendFileSync.*log            (sync file append for logging)
open\(.*log.*\)\.write\(          (Python: sync log file write)

Missing Request/Trace IDs

# API handlers without correlation IDs
app\.(get|post)\(.*req.*res       (check if request ID is propagated)
@app\.route\(                      (check if request ID middleware exists)

Metrics Collection Overhead

# Metrics in hot paths
\.observe\(.*inside.*loop         (Prometheus observe in loop)
\.increment\(.*inside.*loop       (counter increment in loop)
statsd\..*inside.*loop            (StatsD in loop)
\.timing\(.*inside.*loop          (timing metric in loop)
Date\.now\(\).*Date\.now\(\)      (manual timing - use proper instrumentation)
performance\.now\(\).*performance (manual performance timing)

Improvement Strategies

  1. Console.log: Remove from production, use proper logger with levels
  2. Log formatting: Use lazy evaluation - logger.debug("msg %s", expensive_value) vs f-strings
  3. Structured logging: Use JSON structured logs for machine parsing
  4. Async logging: Buffer and flush logs asynchronously, don't block request handling
  5. Request IDs: Add correlation ID middleware, propagate through all service calls
  6. Metrics: Pre-aggregate metrics, use histograms instead of per-request timers in hot loops