7
Back to Problem Dungeon

Logger System

medium

Step 1: Requirements

Requirements

Questions to ask

  1. What log levels? (DEBUG, INFO, WARN, ERROR, FATAL)
  2. Multiple destinations simultaneously? (console, file, remote service)
  3. Structured logging (JSON) or plain text?
  4. Thread/async safety? (Node.js is single-threaded but async writes matter)
  5. Per-module log levels? (e.g., database module at DEBUG, HTTP at WARN)
  6. Log rotation or size limits?
  7. Should it be globally accessible or dependency-injected?

Functional requirements

  • Support log levels: DEBUG, INFO, WARN, ERROR, FATAL
  • Filter: only log messages at or above the configured level
  • Multiple output destinations: console, file, remote HTTP
  • Structured format: timestamp, level, source, message, optional metadata
  • Configurable at runtime (change level without restart)

Non-functional requirements

  • Minimal performance overhead (don't block the main thread)
  • Extensible: new destinations without modifying existing code
  • Testable: mock destinations for unit tests
  • Global access OR injectable — support both patterns

1 / 7 — Requirements