npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tabletcommand-logger

v4.0.0

Published

Tablet Command Logging Configuration

Readme

tabletcommand-logger

Tablet Command shared logging and metrics library for Node.js services.

Version 4.0.0 uses Pino for structured JSON logging to process.stdout.


Features

  • Pino JSON stdout engine: High-performance, low-overhead JSON logging to stdout, ready for container log collection by Datadog Agent.
  • Strict Compile-Time Signature Enforcement: Enforces Pino conventions (obj, msg) or (msg). Legacy Winston-style inverted calls (msg, obj) fail TypeScript compilation with immediate compiler feedback.
  • Redaction: Every log object, child binding, request body and serialized error is walked once, matching key names without case, - or _. Credentials (apiKey, authToken, partnerKey, ...) are cut to a 7-character prefix; passwords, secrets, private keys and personal data are masked (<redacted>).
  • OpenTelemetry Correlation: Built-in mixin automatically detects active OpenTelemetry spans and injects trace_id and span_id without requiring OpenTelemetry packages as hard dependencies.
  • Local Dev Pretty Printing: Enables pino-pretty formatting only when asked for: NODE_ENV=development (outside CI), PINO_PRETTY=true, or pretty: true in the config. Any other environment, including an unset NODE_ENV, writes NDJSON.
  • HTTP Middlewares: Provides loggerMiddleware (backed by pino-http), statusLogger (POST request auditing), and metricsMiddleware (statsd integration).

Installation

npm install tabletcommand-logger

To enable OpenTelemetry trace correlation, install @opentelemetry/api in your service:

npm install @opentelemetry/api

To enable pretty-printed colorized logs in local development, install pino-pretty as a dev dependency:

npm install -D pino-pretty

If omitted, tabletcommand-logger automatically falls back to standard NDJSON stdout without crashing.


Usage

Creating a Logger

import logger, { LoggerConfig } from "tabletcommand-logger";

const config: LoggerConfig = {
  name: "server-location",
  logToConsole: true,
};

const log = logger(config);

Logging Conventions

Pino requires structured metadata objects to be passed as the first argument:

// ✅ Good: Structured object first
log.info({ userId: "123", action: "update" }, "User profile updated");

// ✅ Good: String message only
log.info("Server started on port 3000");

// ✅ Good: Error first
log.error(err, "Failed to connect to database");

// ❌ COMPILE ERROR: String first with object (legacy Winston style)
// TypeScript will reject this call with a compile error:
log.info("User profile updated", { userId: "123" });

HTTP Middleware

import express from "express";
import { logger, loggerMiddleware } from "tabletcommand-logger";

const app = express();
const appLogger = logger({ name: "my-service", logToConsole: true });

app.use(loggerMiddleware(appLogger));

Redaction Policy

Credentials and secrets are redacted before leaving the process:

  • API Keys (apikey, personnelapikey, signupkey, x-tc-auth-token): Truncated to the first 7 characters (e.g. abcdef1...).
  • Authorization headers (Bearer <token>, Basic <cred>): Scheme is preserved and the credential behind it is truncated to 7 characters. Both request (req.headers.authorization) and response (res.headers.authorization) are redacted.
  • Request Cookies (cookie): Cookie names are preserved, values are masked with <redacted>.
  • Response Set-Cookie (set-cookie): Redacts only the first pair's cookie value (<name>=<redacted>) while leaving security attributes (Path, Domain, Max-Age, HttpOnly, Secure, SameSite) intact for auditing visibility.
  • Key matching: names are compared lowercased with - and _ removed, so authToken, AUTH_TOKEN and auth-token are the same key. The list in src/redaction.ts comes from an audit of massive-tyrion and tabletcommand-backend-models.
  • Prefix kept (7 characters): any name containing apikey (departmentApiKey, x-api-key, ...), any name ending in token except pagination cursors (accessToken, refresh_token, x-tc-auth-token, ...), and signupKey, partnerKey, cadKey, vendorKey, licenseKey, licenseCode, mark43Key, authKey, accessCode, joinCode, jwt, authHeader, sessionCookie.
  • Completely masked (<redacted>): any name containing password, passwd, passphrase, secret, credential, privateKey, signingKey or encryptionKey, and pass, pwd, auth_pass, salt, ssn, dateOfBirth, licenseNumber, doorCode.
  • Booleans, numbers and null under a secret name (hasAuthSecret, minPasswordLength) are left readable.
  • Objects with toJSON (Mongoose documents, axios errors) are redacted as they serialize. The caller's object is never changed.
  • Depth Limit (MAX_REDACT_DEPTH = 10): values nested deeper are written as they are.

Changelog

4.0.0

  • Breaking: Migrated from Winston to Pino for high-performance JSON logging directly to stdout.
  • Breaking: Enforced strict (obj, msg) signature at compile time; legacy Winston inverted calls (msg, obj) fail TypeScript build.
  • Added: Built-in OpenTelemetry mixin extracting trace_id and span_id when active spans exist.
  • Added: Express HTTP middleware powered by pino-http with response and request header redaction (res.headers["set-cookie"], res.headers.authorization).
  • Added: Configurable and automatic pretty printing via pino-pretty in local development with fallback to NDJSON stdout.
  • Added: Key-based redaction of log objects, bindings, request bodies and errors, up to 10 levels deep (MAX_REDACT_DEPTH = 10).