Git Product home page Git Product logo

pino-filter's Introduction

pino-filter

npm version Build Status Coverage Status js-standard-style

Lead maintainer: James Sumners

pino-filter is a transport for Pino that allows filtering of log lines based on logger names, similar to the funtionality of filters in the debug module.

Logs that match any filters are written to stdout. By default, pino-filter will pass through all received logs at the info level or higher. To define filters, a configuration file must be supplied that provides a mapping of filters to log levels. For example, you can supply a simple JSON file:

{
  "levels": {
    "*": "info",
    "foo:bar": "debug",
    "baz:*": "trace"
  }
}

Usage

$ node the-app.js | pino-filter ./config.json

Config

module.exports = {
  levels: {
    '*': 'info', // catch-all filter
    'foo:bar': 'debug',
    'baz:*': 'trace'
  },
  values: {
    fatal: 60,
    error: 50,
    warn: 40,
    info: 30,
    debug: 20,
    trace: 10
  }
}
  • levels: a mapping of filters (keys) to log levels (level names). Note: the wildcard * may only be used at the end of a filter, e.g. foo:* is valid but foo:*:bar is not.
  • values: a mapping of level names to their numeric value. The default is set to the standard Pino levels. If custom levels are defined in the application, those level values should be defined here.

Note: the configuration file can be reloaded at runtime by sending the SIGHUP signal to the pino-filter process.

pino-filter's People

Contributors

10xlacroixdrinker avatar dependabot[bot] avatar fdawgs avatar jsumners avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pino-filter's Issues

Put the package on npm?

Hi,

If I am not mistaken, this library is not on npm right now. Would you please put it there?

Pavel

Command never outputs anything

I've been playing with this because it seems incredibly useful, and it doesn't work. It never outputs anything :(

It seems that the problem is down to require.main === module in index.js. This always returns false for me, no matter what.

This is on Node v18.7.0, and I've been running the tool with both npx pino-filter and node ./node_modules/.bin/pino-filter. If I change that conditional to always be true then it works great, but for some reason with it as-is it doesn't work :(

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.