{"id":13464897,"url":"https://github.com/pinojs/pino-caller","last_synced_at":"2025-04-12T22:35:40.191Z","repository":{"id":18492817,"uuid":"82339352","full_name":"pinojs/pino-caller","owner":"pinojs","description":"🌲 Include call site of pino log messages","archived":false,"fork":false,"pushed_at":"2024-10-19T08:57:06.000Z","size":179,"stargazers_count":57,"open_issues_count":10,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-29T17:56:12.816Z","etag":null,"topics":["caller","debug","logger","logging","pino","productivity","utility"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pinojs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-17T21:25:23.000Z","updated_at":"2024-10-19T08:57:06.000Z","dependencies_parsed_at":"2024-01-16T05:41:05.583Z","dependency_job_id":"f8b2b8ca-0b0b-4545-8a37-87c7f542f1fe","html_url":"https://github.com/pinojs/pino-caller","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinojs%2Fpino-caller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinojs%2Fpino-caller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinojs%2Fpino-caller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinojs%2Fpino-caller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pinojs","download_url":"https://codeload.github.com/pinojs/pino-caller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248642487,"owners_count":21138351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caller","debug","logger","logging","pino","productivity","utility"],"created_at":"2024-07-31T14:00:52.396Z","updated_at":"2025-04-12T22:35:40.154Z","avatar_url":"https://github.com/pinojs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## pino-caller\n[![npm version](https://img.shields.io/npm/v/pino-caller)](https://www.npmjs.com/package/pino-caller)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/pinojs/pino-caller/ci.yml?branch=master)](https://github.com/pinojs/pino-caller/actions)\n[![Coverage Status](https://coveralls.io/repos/github/pinojs/pino-caller/badge.svg?branch=master)](https://coveralls.io/github/pinojs/pino-caller?branch=master)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n\n### Description\n`pino-caller` is a wrapper for [pino](https://github.com/pinojs/pino) which adds the call site of each log message to the log output.\nThis can be useful when developing with large codebases in order to locate the exact point where pino is invoked.\n\n### Install\n\nFor Pino v4 and below use the v2 line, which can be installed with the `@legacy` tag:\n\n```sh\nnpm install pino-caller@legacy\n``` \n\nFor Pino v5 and above use the v3+ line, which will install using the usual command:\n\n```\nnpm install pino-caller\n```\n\n**WARNING: THIS IS A DEVELOPMENT TOOL AVOID PRODUCTION USE!**\n\n### Usage\n\n#### Basic\n```js\n'use strict'\n\nconst pino = require('pino')() // it will print as usual\nconst pinoCaller = require('pino-caller')(pino) // it will print also the calling site\n\npinoCaller.info('info1')\npinoCaller.error('error1')\npinoCaller.debug('debug1')\n```\n\n#### Advanced\n```js\n'use strict'\n// dynamically load the plugin if in development environment, output paths relative to __dirname\nconst pino = process.env.NODE_ENV === 'development' ? require('pino-caller')(require('pino')(), { relativeTo: __dirname }) : require('pino')()\n\npino.info('info1')\npino.error('error1')\npino.debug('debug1')\n```\n\nYou can find also a working example in the `examples` directory and you can run it with `npm run example`\n\n##### Options\n\n- **relativeTo** - Remove path prefixes from log messages to make them easier to read.\n- **stackAdjustment** - For those who've wrapped pino, make pino-caller move N stackframes up to get a meaningful message.\n\n```js\n'use strict'\nconst pino = require('pino')()\nconst pinoCaller = require('pino-caller')(pino, { relativeTo: __dirname, stackAdjustment: 1 })\n\n// People who have wrapped pino like in the contrived example below \n// will want to use stackAdjustment.\n// Most people will NOT need this.  See issue #90 for details.\nconst log = {\n  info: function(message) { pinoCaller.info(message) }\n}\n```\n\n### Example output\n\n```\n╭─phra at debian in /home/phra/git/pino-caller (master ✔)\n╰─λ npm run example\n\n\u003e pino-caller@1.0.0 example /home/phra/git/pino-caller\n\u003e env NODE_ENV=development node examples/index.js\n\n{\"pid\":44837,\"hostname\":\"debian\",\"level\":30,\"time\":1487873713227,\"msg\":\"hello from the module!\",\"caller\":\"Object.\u003canonymous\u003e (/home/phra/git/pino-caller/examples/module.js:4:12)\",\"v\":1}\n{\"pid\":44837,\"hostname\":\"debian\",\"level\":30,\"time\":1487873713230,\"msg\":\"info1\",\"caller\":\"Object.\u003canonymous\u003e (index.js:8:12)\",\"v\":1}\n{\"pid\":44837,\"hostname\":\"debian\",\"level\":50,\"time\":1487873713230,\"msg\":\"error1\",\"caller\":\"Object.\u003canonymous\u003e (index.js:9:12)\",\"v\":1}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinojs%2Fpino-caller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinojs%2Fpino-caller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinojs%2Fpino-caller/lists"}