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

pino-tee

v0.4.0

Published

Tee pino logs into a file, with multiple levels

Readme

pino-tee

Tee pino logs into multiple files, according to the given levels.

Works with any newline delimited json stream.

Install

npm i pino-tee -g

Usage

CLI

Specify a minimum log level to write to file.

The following writes info, warn and error level logs to ./info-warn-error-log, and all output of app.js to ./all-logs:

node app.js | pino-tee info ./info-warn-error-logs | tee -a ./all-logs

(using tee -a ./all-logs will both write to ./all-logs and stdout, enabling piping of more pino transports)

Pino V7+
const pino = require('pino')

const pinoTee = pino.transport({
  target: 'pino-tee',
  options: {
    filters: {
      info: 'info.log',
      warn: 'warn.log'
    }
  }
})

const logger = pino(pinoTee)

logger.info('example info log')
logger.error('example error log')
NodeJS

You can log to multiple files by spawning a child process. In the following example pino-tee writes into three different files for warn, error & fatal log levels.

const pino = require('pino')
const childProcess = require('child_process')
const stream = require('stream')

// Environment variables
const cwd = process.cwd()
const { env } = process
const logPath = `${cwd}/log`

// Create a stream where the logs will be written
const logThrough = new stream.PassThrough()
const log = pino({ name: 'project' }, logThrough)

// Log to multiple files using a separate process
const child = childProcess.spawn(process.execPath, [
  require.resolve('pino-tee'),
  'warn', `${logPath}/warn.log`,
  'error', `${logPath}/error.log`,
  'fatal', `${logPath}/fatal.log`
], { cwd, env, stdio: ['pipe', 'inherit', 'inherit'] })

logThrough.pipe(child.stdin)

// Writing some test logs
log.warn('WARNING 1')
log.error('ERROR 1')
log.fatal('FATAL 1')

This prints raw logs into log files, you can also print pretty logs to the console for development purposes. For that, you need to use pino-multi-stream. See the example below

const pinoms = require('pino-multi-stream')
const childProcess = require('child_process')
const stream = require('stream')

const cwd = process.cwd()
const { env } = process

const logThrough = new stream.PassThrough()
const prettyStream = pinoms.prettyStream()
const streams = [
  { stream: logThrough },
  { stream: prettyStream }
]
const log = pinoms(pinoms.multistream(streams))

const child = childProcess.spawn(process.execPath, [
  require.resolve('pino-tee'),
  'warn', `${__dirname}/warn`,
  'error', `${__dirname}/error`,
  'fatal', `${__dirname}/fatal`
], { cwd, env })

logThrough.pipe(child.stdin)

// Writing some test logs
log.warn('WARNING 1')
log.error('ERROR 1')
log.fatal('FATAL 1')

Here, we're tapping into the write stream that pino-tee gets and manually formatting the log line using pino-pretty to write on the stdout. Note that the pretty printing is typically only done while developing.

API

pinoTee(source)

Create a new tee instance from source. It is an extended instance of cloneable-readable.

Example:

const { tee } = require('pino-tee')
const fs = require('fs')
const stream = tee(process.stdin)
stream.tee(fs.createWriteStream('errors'), line => line.level >= 50)
stream.pipe(process.stdout)

stream.tee(dest, [filter])

Create a new stream that will filter a given line based on some parameters. Each line is automatically parsed, or skipped if it is not a newline delimited json.

The filter can be a function with signature filter(line), where line  is a parsed JSON object. The filter can also be one of the pino levels either as text or as a custom level number, in that case all log lines with that level or greater will be written.

Acknowledgements

This project was kindly sponsored by nearForm.

License

MIT