@vanillas/chalk-console-logger
v1.0.0
Published
An enhanced version of @vanillas/console-logger which injects an instance of chalk into any functions passed into a logger method
Downloads
6
Maintainers
Readme
Chalk Console Logger
A wrapper around the native Console API but which supports top-down threshold (levels) based control and injects an instance of the chalk into any functions passed into the @vanillas/console-logger methods.
Installation
npm install @vanillas/chalk-console-logger
Usage
Try it out in the NodeJs shell either next to a node_modules/
directory where @vanillas/console-logger
has been installed, or try using replem as a global NPM package so you can load any NPM package into a NodeJs shell.
$ replem @vanillas/chalk-console-logger:logger
Installed into REPL context:
- @vanillas/[email protected] as logger
> logger.level
'info'
> logger.setLevel("trace")
> logger.trace("Some very verbose logging statement")
Some very verbose logging statement
> logger.setLevel("debug")
> logger.trace("Some very verbose logging statement")
> logger.debug("Some slightly less verbose logging statement")
Some slightly less verbose logging statement
> logger.setLevel("warn")
> logger.info("Normal stuff to log to stdout")
> logger.error("something broke"
something broke
The only thing happening in this example is writing normal logging statements but the ones below the current logger threshold level never show up.
A NodeJs shell is just a quick way to demonstrate functionality for a simple package like this one, but in a front-end or back-end JavaScript/TypeScript appliction you instead just import
this package and use it in the same manner demonstrated in the shell.