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-template

v1.0.4

Published

An Eta template transport for the pino logging library

Readme

Issues MIT

An Eta template transport for the pino logging library

About The Project

This is a pipeline transport for the pino.js logging library, which allows you to transform the logging output by applying an Eta template.

For those unfamiliar with Eta, perhaps you've encountered EJS. Eta templates are very similar to EJS templates.

e.g.

template

<%
  // extract the context and this log message from `it`
  const {data: d, context: ctx} = it;
  // get the name of the level from the mapping provided as context
  const levelName = (ctx?.[d.level] ?? d.level).toUpperCase(); // e.g. "INFO"
%><%=
  // output our formatted log message as a string
  `${
    new Date(d.time)
      .toISOString()
      .substring(0, 19)
  } - ${
   levelName
  } - ${
   d.msg
  }`
%>

input

{"levelName":"info","level":30,"time":1531171074631,"msg":"hello world","pid":657,"hostname":"Davids-MBP-3.fritz.box"}

result

2018-07-09T21:17:54 - INFO - hello world

Built With

  • TypeScript
  • Node.js
  • Eta

Getting Started

Prerequisites

While this project has no dependencies, it does have the following peerDependencies:

  • pino@^10.1.0

    npm install "pino@^10.1.0" --save
  • eta@^4.0.1

    npm install "eta@^4.0.1" --save
  • Node versions: This project is tested on Node 24.12.0 .

  • ES Module: This project is only available as an ES module (a.k.a. "ESM") i.e. it probably won't work in CommonJS, except perhaps using dynamic import.

Installation

  1. Ensure you've installed the prerequisites above.
  2. Install this NPM package (pino-template):
    npm install pino-template --save

Usage

Combine pino-template (this module) as part of a pino transport pipeline.

Options

| option | description | example | | ----------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------- | | template | The Eta template as a string. Each log message will be available as it.data. Required. | <%= it.data.msg + it.context.foo %> | | templateContext | An object which will be made available to the Eta template as it.context . Optional. | {"foo":"bar"} | | templateOptions | Options which will be passed to the Eta constructor . Optional. | {"debug":false,"cache":false,"autoEscape":false} |

Example

The example below adds an extra "levelName" property to each JSON log line i.e. it changes this:

{"level":30,"time":1531171074631,"msg":"hello world","pid":657,"hostname":"Davids-MBP-3.fritz.box"}

into this:

{"levelName":"info","level":30,"time":1531171074631,"msg":"hello world","pid":657,"hostname":"Davids-MBP-3.fritz.box"}
import pino from 'pino'

const logger = pino({
  transport: {
    pipeline: [{
      target: 'pino-template',
      options: {
        // Provide the Eta template here as the "template" property value. The `"it.data"`
        //  object contains the log data (i.e. level, time, msg, hostname etc); while 
        //  the `"it.context"` object contains whatever you provide as the 
        //  `"templateContext"` property below
        template: `<%
        const {context, data} = it; 
      %><%= 
        JSON.stringify({...data, "levelName":context?.levelMapping?.[data.level] ?? data.level}) 
      %>`,
        templateContext: { levelMapping: pino.levels.labels },
      },
    }, {
      // Use target: 'pino/file' with STDOUT descriptor 1 to write
      // logs without any change.
      target: 'pino/file',
      options: { destination: 1 }
    }]
  }
})

logger.info('hello world')

License

Distributed under the MIT license. See LICENSE.txt for more information.

Project Link

https://github.com/cunneen/pino-template