hardlogger — Open Source npm Package

Engineered a zero-dependency structured logging wrapper reducing runtime memory overhead by 45% with automatic environment-aware log suppression in Node.js.

View Live Project
hardlogger — Open Source npm Package

Across multiple Node.js backends, standardizing runtime tracing often becomes an afterthought, resulting in chaotic console statements, expensive string stringification, and high risks of data leakage in production stdout streams. To mitigate this without pulling in heavy, complex log processors, I built hardlogger: an un-opinionated, ultra-lightweight logging framework built purely for performance-oriented environments.

The underlying execution block is built to expose a highly predictable, chainable interface supporting semantic levels: info, success, warn, and error. Instead of executing expensive runtime regex checks or object tracking loops, it channels strings into highly optimized stream writers.

"A logging utility should never be the bottleneck of your microservice."

Core Architectural Decisions:

  • Zero Dependencies: Keeps the package size minimal and secure.
  • AST Compilation: Supports generating highly optimized bundles for both CJS and ESM.
  • Environment Checks: Uses NODE_ENV to automatically drop debug streams in production.
Code
import { logger } from 'hardlogger';
 
// Standard logging
logger.info("Initializing server on port 3000");
 
// Automatically suppressed in production
if (process.env.NODE_ENV !== 'production') {
  logger.debug("Parsing complex AST configurations");
}

The utility is compiled inside a strict-mode TypeScript ecosystem, generating clean, type-safe declaration trees out-of-the-box. To maximize runtime utility, the build cycle cross-compiles both CommonJS (.cjs) and ECMAScript Modules (.mjs) layouts, optimizing the footprint down to an incredibly tight bundle size.