Sequence NODE_225
Medium

Create a Simple Logger Module

Node.js
Technical Specification

Create a logger module that logs messages with timestamps and levels (info, warn, error).

Input/Output Samples
Input:logger.info("Server started")
Output:[INFO] 2025-01-01T... Server started
Optimal Logic Path
// logger.js
function log(level, msg) {
  const ts = new Date().toISOString();
  console.log(`[${level.toUpperCase()}] ${ts} - ${msg}`);
}
module.exports = {
  info: (msg) => log("info", msg),
  warn: (msg) => log("warn", msg),
  error: (msg) => log("error", msg),
};
Architectural Deep-Dive
We wrap console.log with a helper that formats messages consistently and expose level-specific functions.