Giter Site home page Giter Site logo

pino-caller's Introduction

pino-caller  Coverage Status Build Status

Description

pino-caller is a wrapper for pino which adds the call site of each log message to the log output. This can be useful when developing with large codebases in order to locate the exact point where pino is invoked.

Install

For Pino v4 and below use the v2 line, which can be installed with the @legacy tag:

npm install pino-caller@legacy

For Pino v5 and above use the v3+ line, which will install using the usual command:

npm install pino-caller

WARNING: THIS IS A DEVELOPMENT TOOL AVOID PRODUCTION USE!

Usage

Basic

'use strict'

const pino = require('pino')() // it will print as usual
const pinoCaller = require('pino-caller')(pino) // it will print also the calling site

pinoCaller.info('info1')
pinoCaller.error('error1')
pinoCaller.debug('debug1')

Advanced

'use strict'
// dynamically load the plugin if in development environment
const pino = process.env.NODE_ENV === 'development' ? require('pino-caller')(require('pino')()) : require('pino')()

pino.info('info1')
pino.error('error1')
pino.debug('debug1')

You can find also a working example in the examples directory and you can run it with npm run example

Example output

╭─phra at debian in /home/phra/git/pino-caller (master ✔)
╰─λ npm run example

> [email protected] example /home/phra/git/pino-caller
> env NODE_ENV=development node examples/index.js

{"pid":44837,"hostname":"debian","level":30,"time":1487873713227,"msg":"hello from the module!","caller":"Object.<anonymous> (/home/phra/git/pino-caller/examples/module.js:4:12)","v":1}
{"pid":44837,"hostname":"debian","level":30,"time":1487873713230,"msg":"info1","caller":"Object.<anonymous> (/home/phra/git/pino-caller/examples/index.js:8:12)","v":1}
{"pid":44837,"hostname":"debian","level":50,"time":1487873713230,"msg":"error1","caller":"Object.<anonymous> (/home/phra/git/pino-caller/examples/index.js:9:12)","v":1}

pino-caller's People

Contributors

phra avatar mcollina avatar karanssj4 avatar jeromemacias avatar

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.