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

@philiprehberger/ts-logger

v0.3.3

Published

Structured JSON logger with child loggers, redaction, and pretty dev output

Readme

@philiprehberger/ts-logger

CI npm version License

Structured JSON logger with child loggers, redaction, and pretty dev output.

Installation

npm install @philiprehberger/ts-logger

Usage

Basic

import { createLogger } from '@philiprehberger/ts-logger';

const logger = createLogger({ name: 'api', level: 'info' });

logger.info('Server started', { port: 3000 });
// {"level":"info","name":"api","msg":"Server started","port":3000,"ts":"2026-03-09T..."}

logger.error('Request failed', { status: 500, path: '/api/users' });

Log Levels

tracedebuginfowarnerrorfatalsilent

Messages below the configured level are silently dropped. Use silent to disable all output (useful in tests).

Child Loggers

const reqLogger = logger.child({ requestId: 'abc-123' });
reqLogger.info('Processing request');
// {"level":"info","name":"api","msg":"Processing request","requestId":"abc-123","ts":"..."}

const dbLogger = reqLogger.child({ service: 'database' });
// Inherits requestId + adds service

Auto-Redaction

Sensitive fields are automatically masked:

logger.info('Auth', { token: 'secret123', user: 'alice' });
// {"level":"info","name":"api","msg":"Auth","token":"[REDACTED]","user":"alice","ts":"..."}

Default redacted patterns: password, token, secret, authorization, cookie, key, credential, api_key, access_token, refresh_token, private_key.

Custom patterns:

const logger = createLogger({
  name: 'app',
  redact: ['ssn', 'credit_card', 'password'],
});

Arrays are redacted recursively:

logger.info('Users', { users: [{ name: 'alice', token: 'abc' }] });
// token is redacted inside the array element

Circular references are handled safely:

const obj: any = { name: 'test' };
obj.self = obj;
logger.info('Circular', obj);
// self becomes "[Circular]"

Disable redaction:

const logger = createLogger({ name: 'app', redact: false });

Pretty Mode

Auto-detected in development (NODE_ENV=development), or set manually:

const logger = createLogger({ name: 'app', pretty: true });
// INFO  [app] Server started {"port":3000}

Runtime Level Changes

const logger = createLogger({ name: 'app', level: 'info' });
logger.debug('hidden'); // dropped

logger.setLevel('debug');
logger.debug('now visible'); // logged

// Child loggers inherit the parent's level unless they set their own
const child = logger.child({ req: '123' });
logger.setLevel('error'); // child also uses 'error' now
child.setLevel('debug');  // child overrides to 'debug'

Environment Variables

  • LOG_LEVEL — sets the log level (overrides constructor option, case-insensitive)
  • NODE_ENV=development — enables pretty mode by default

Custom Colors

import { consoleTransport } from '@philiprehberger/ts-logger';

const transport = consoleTransport({
  pretty: true,
  colors: { error: '\x1b[41m', info: '\x1b[36m' },
});

Development

npm install
npm run build
npm test

License

MIT