Skip to content

Logging

Easy — everyone uses thisGeneral Dev

ELI5 — The Vibe Check

Logging is writing a diary for your program. Every time something important happens — a user logs in, an error occurs, a payment is processed — you write it down with a timestamp. When something breaks at 3am, the logs are your only witness to what happened.

Real Talk

Logging is the practice of recording events, errors, and diagnostic information during program execution. Logs are structured with levels (DEBUG, INFO, WARN, ERROR, FATAL) to filter by severity. Production systems send logs to centralized services (Datadog, Loki, CloudWatch) for search, alerting, and analysis. Structured logging (JSON format) is preferred over plain text for machine parsing.

Show Me The Code

// Basic console logging (development):
console.log('User logged in:', userId);
console.error('Payment failed:', error);

// Structured logging with a library (production):
import logger from './logger'; // e.g. pino, winston
logger.info({ userId, action: 'login' }, 'User authenticated');
logger.error({ error, orderId }, 'Payment processing failed');

When You'll Hear This

"Check the logs for the error." / "Add a log statement before the API call so we can trace it."

Made with passive-aggressive love by manoga.digital. Powered by Claude.