selected works

works

hardlogger — Open Source npm Package

Case study / 2025

hardlogger — Open Source npm Package

Live siteSource

Zero-dependency, environment-aware logging for Node.js with compile-time production log stripping and a chainable info/success/warn/error API.

npmjs.com

hardlogger terminal output, showing coloured SUCCESS, ERROR, WARNING and INFO log levels.

Period

2025

Stack

  • Node.js
  • TypeScript
  • npm

By the numbers

npm downloads (lifetime)
1.1K
Dependencies
0
Latest version
1.2.1

01 / Problem

Teams kept shipping styled loggers with runtime regex checks, object tracking and production log noise leaking into customer-facing stdout — a dependency and a data-leak risk for what should be a printf.

02 / Role

Solo author and maintainer, published to npm.

03 / Decisions

  1. 01

    Zero dependencies, enforced. One dependency turns into three in a year, and this thing runs in every environment you own.

  2. 02

    Detect the runtime, do not configure it. Auto-switching between Node ANSI output and browser console styling is what makes the call site stay one line.

  3. 03

    Ship CJS and ESM with real type declarations. Dropping people into an untyped package failed the first time they used it in TypeScript.

  4. 04

    Be straight about the numbers. An earlier version of this page claimed production memory savings and 400+ weekly installs; neither survived checking the npm registry. The metrics here are the real ones.

04 / Outcome

1.1K lifetime npm installs, zero dependencies, v1.2.1 on npm. The honest lesson is that technical merit did not drive adoption — distribution did, and I am still fixing that.

Build notes

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.
typescript
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.