Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
console-caller
Advanced tools
console-caller lets you easily print the call site of console functions. It can be useful in large codebases where there are a lot of logs. Do you want to easily find out which line of your code is printing that thing? This is the right module for you!
console-caller
lets you easily print the call site of console functions. It can be useful in large codebases where there are a lot of logs. Do you want to easily find out which line of your code is printing that thing? This is the right module for you!
npm i --save-dev console-caller
or
yarn add --dev console-caller
This is the most basic way to use this tool.
require('console-caller')()
// All console calls will be intercepted.
It's better if we include this tool only when developing, since it's not useful in a production environment.
const console = process.env.NODE_ENV === 'development' ? require('console-caller')() : ((typeof window !== 'undefined' && window.console) || (typeof global !== 'undefined' && global.console))
// All console calls will be intercepted when in development environment.
You can also configure console-caller
to track only console calls for certain files in this way.
const console = require('console-caller')(Object.assign(Object.create(null), global.console))
// Placed on top of a file, it will only track the calls in that file.
If you are using some abstractions between your logging functions and the real call to console APIs, you can set an arbitrary offset when splitting the stack trace. In this way you can also use this utility when a custom library is used for logging.
const console = require('console-caller')(Object.assign({}, ((typeof window !== 'undefined' && window.console) || (typeof global !== 'undefined' && global.console))), 10)
// Note the "10" as second argument. That is the offset of the splitted stack trace
npm run example
or yarn run example
╭─phra at debian in /home/phra/git/console-caller (master ✔)
╰─λ yarn run example 0 < 13:36:37
yarn run v0.22.0
$ env NODE_ENV=development node examples/example.js
hi from module!
example {caller: [Object.<anonymous> (/home/phra/git/console-caller/examples/example.js:6:9)]}
hi from module! {caller: [module.exports (/home/phra/git/console-caller/examples/module.js:1:94)]}
example {caller: [Object.<anonymous> (/home/phra/git/console-caller/examples/example.js:9:9)]}
example {caller: [Object.<anonymous> (/home/phra/git/console-caller/examples/example.js:10:9)]}
example {caller: [Object.<anonymous> (/home/phra/git/console-caller/examples/example.js:11:9)]}
Done in 0.17s.
FAQs
console-caller lets you easily print the call site of console functions. It can be useful in large codebases where there are a lot of logs. Do you want to easily find out which line of your code is printing that thing? This is the right module for you!
The npm package console-caller receives a total of 1 weekly downloads. As such, console-caller popularity was classified as not popular.
We found that console-caller demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.