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

@fishka/logs

v1.0.0

Published

Console.log transformation pipes

Downloads

3,289

Readme

@fishka/logs

Console.log transformation pipes for structured logging in TypeScript.

Installation

npm install @fishka/logs

Quick Start

import {createJsonStringifyPipe, installConsoleOverride} from '@fishka/logs';

// Install JSON stringify pipe
installConsoleOverride(createJsonStringifyPipe());

// Now all console logs are JSON formatted
console.log('User logged in', {userId: 123, action: 'login'});
// Output: {"message":"User logged in $1","$1":{"userId":123,"action":"login"},"level":"log","timestamp":"2026-02-15T04:30:00.000Z","message_id":"a1b2c3d4-e5f6-7890-abcd-ef1234567890"}

Pipes

JsonStringifyPipe

Converts console arguments to a JSON string:

import {createJsonStringifyPipe, installConsoleOverride} from '@fishka/logs';

installConsoleOverride(createJsonStringifyPipe());

console.log('Hello', {data: 'value'});
// {"message":"Hello $1","$1":{"data":"value"},"level":"log","timestamp":"...","message_id":"..."}

JsonPipe

Converts console arguments to a JSON object (without stringifying):

import {createJsonPipe, installConsoleOverride} from '@fishka/logs';

const pipe = createJsonPipe();
installConsoleOverride(pipe);

// Access last message ID
console.log('Test');
console.log(pipe.getLastMessageId()); // "a1b2c3d4-..."

// Set next message ID
pipe.setNextMessageId('custom-id-123');
console.log('Test'); // Uses "custom-id-123" as message_id

LogLevelFilterPipe

Filter logs by level:

import {createLogLevelFilterPipe, installConsoleOverride} from '@fishka/logs';

// Exclude debug and trace logs
installConsoleOverride(createLogLevelFilterPipe({
    excludedLogLevels: ['debug', 'trace']
}));

console.debug('This will not appear');
console.log('This will appear');

LogMessageFilterPipe

Filter logs by message content:

import {createLogMessageFilterPipe, installConsoleOverride} from '@fishka/logs';

// Exclude messages containing "password"
installConsoleOverride(createLogMessageFilterPipe({
    excludedMessagePatterns: [/password/i]
}));

console.log('User password: secret123'); // Filtered out
console.log('User login: john'); // Allowed

LogCachePipe

Cache recent logs:

import {createLogCachePipe, installConsoleOverride} from '@fishka/logs';

const cachePipe = createLogCachePipe({maxCacheSize: 100});
installConsoleOverride(cachePipe);

console.log('Message 1');
console.log('Message 2');

// Access cached logs
console.log(cachePipe.getLogCache()); // Array of recent logs

DateTimePipe

Add timestamps to logs:

import {createDateTimePipe, installConsoleOverride} from '@fishka/logs';

installConsoleOverride(createDateTimePipe());

console.log('Event');
// [2026-02-15T04:30:00.000Z] Event

Combining Pipes

Install multiple pipes in order:

import {
    createLogLevelFilterPipe,
    createJsonStringifyPipe,
    installConsoleOverrides
} from '@fishka/logs';

installConsoleOverrides(
    createLogLevelFilterPipe({excludedLogLevels: ['debug']}),
    createJsonStringifyPipe()
);

Uninstalling Pipes

import {uninstallConsoleOverride, uninstallAllConsoleOverrides} from '@fishka/logs';

// Remove specific pipe
uninstallConsoleOverride(pipe);

// Remove all pipes
uninstallAllConsoleOverrides();

Custom Pipe

Create your own pipe:

import {LogPipe, installConsoleOverride} from '@fishka/logs';

const myPipe: LogPipe = (level, ...args) => {
    // Transform arguments
    return args.map(arg => typeof arg === 'string' ? arg.toUpperCase() : arg);
};

installConsoleOverride(myPipe);

console.log('hello'); // HELLO

Suppress logs by returning empty array:

const suppressPipe: LogPipe = () => [];

Change log level by returning object:

const upgradePipe: LogPipe = (level, ...args) => ({
    level: 'error', // Upgrade all logs to error
    args
});

License

Apache-2.0