Gathering detailed insights and metrics for loglevel-colored-level-prefix
Gathering detailed insights and metrics for loglevel-colored-level-prefix
npm install loglevel-colored-level-prefix
Typescript
Module System
Node Version
NPM Version
98.5
Supply Chain
100
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
146,706,221
Last Day
157,928
Last Week
821,461
Last Month
3,274,209
Last Year
41,042,121
14 Stars
1 Commits
1 Forks
3 Watching
8 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
loglevel-colored-level-prefix@1.0.0
Size
4.57 kB
NPM Version
3.10.10
Node Version
6.10.0
Publised On
27 Feb 2017
Cumulative downloads
Total Downloads
Last day
5.1%
157,928
Compared to previous day
Last week
28.9%
821,461
Compared to previous week
Last month
24.3%
3,274,209
Compared to previous month
Last year
28.1%
41,042,121
Compared to previous year
loglevel plugin that adds colored level prefix (node only)
loglevel
is great, and I find that I often want the log output to
be formatted the same way every time. Also I don't really like some of the
implementation of loglevel
(specifically the fact that it uses some browser
APIs for some things.
This exposes a function to get a logger (singleton) with colored prefixes for
the level. Note that this only works in Node because it uses chalk
.
This module is distributed via npm which is bundled with node and should
be installed as one of your project's dependencies
:
npm install --save loglevel-colored-level-prefix
1const getLogger = require('loglevel-colored-level-prefix') 2const options = {prefix: 'your-prefix', level: 'trace'} 3const logger = getLogger(options) 4logger.trace('WOW! What the stack trace!?') 5// Trace: your-prefix [TRACE]: WOW! What the stack trace!? 6// at Logger.trace (<full-path>/node_modules/loglevel-colored-level-prefix/dist/index.js:54:24) 7// at ... etc 8logger.debug('sup debug?') 9// your-prefix [DEBUG]: sup debug? 10logger.info('Hey info') 11// your-prefix [INFO]: Hey info 12logger.warn('Hi warn') 13// your-prefix [WARN]: Hi warn 14logger.error('Hello error') 15// your-prefix [ERROR]: Hello error
Let's look at what that actually looks like...
?String - Whatever you want your prefix to be. Normally this is the tool
that you're logging for. The getLogger
function will return the same instance
of the logger based on the given prefix.
?String - What you want the initial level to be set to. This defaults to:
process.env.LOG_LEVEL || 'warn'
. Possible options are (in order of verbosity):
trace
, debug
, info
, warn
, error
.
An instance of a loglevel
logger. Learn more about that API from the
loglevel
docs.
I wrote this because I wanted to use the plugin I created for
prettier-eslint
in
prettier-eslint-cli
. And I'll probably use it in other
projects/tools as well.
I'm unaware of other plugins for loglevel
that do what this one does. But
there are many logging solutions out there...
Thanks goes to these people (emoji key):
Kent C. Dodds ???? ???? ???? ⚠️ |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is archived
Details
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
101 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More