Structured Console Logger (utils/logger.ts)

nitrostack · sample-apps/seizure-monitor/VeriCite-Citation-Integrity-Auditor/src/modules/verification/utils/logger.ts · typescript · Apache-2.0
infra, dev-tools, lang:typescript, fw:node, tag:knn-classified, tag:utility

Provides leveled logging (debug/info/warn/error) with colored output, timestamps, and environment-configurable log level for Node.js applications.

// Source: https://github.com/nitrocloudofficial/nitrostack | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * VeriCite – Verification Engine
 * utils/logger.ts — Structured, levelled console logger
 */

export type LogLevel = "debug" | "info" | "warn" | "error";

const LOG_LEVELS: Record<LogLevel, number> = {
  debug: 0,
  info: 1,
  warn: 2,
  error: 3,
};

const LEVEL_COLORS: Record<LogLevel, string> = {
  debug: "\x1b[36m", // cyan
  info: "\x1b[32m",  // green
  warn: "\x1b[33m",  // yellow
  error: "\x1b[31m", // red
};

const RESET = "\x1b[0m";

function getEnvLevel(): LogLevel {
  const raw = (process.env["LOG_LEVEL"] ?? "info").toLowerCase();
  if (raw in LOG_LEVELS) 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key