Installations
npm install loglevel-prefix-persist
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
6.2.0
NPM Version
3.8.9
Score
47
Supply Chain
94.5
Quality
74.9
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
ftliou
Download Statistics
Total Downloads
3,090
Last Day
1
Last Week
1
Last Month
26
Last Year
159
GitHub Statistics
14 Commits
2 Forks
1 Watching
1 Branches
1 Contributors
Bundle Size
1.31 MB
Minified
211.73 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.3
Package Id
loglevel-prefix-persist@1.0.3
Size
3.67 kB
NPM Version
3.8.9
Node Version
6.2.0
Total Downloads
Cumulative downloads
Total Downloads
3,090
Last day
0%
1
Compared to previous day
Last week
-75%
1
Compared to previous week
Last month
271.4%
26
Compared to previous month
Last year
-15.9%
159
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
loglevel-prefix-persist
loglevel plugin - Support for the following:
- (Almost) Isomorphic - passes single log config that can be used on both client and server
- can be used by client or server alone
- client & server log message prefix with [your/module-name]
- client & server log persistence
- additional datetime information, text color to server log
Uses
- file-stream-rotator to rotate logs daily
- node-schedule to clean up files over configured maximum number of log files
#Usage Assuming the following simple config
1var logCfg = { 2 "level":{ 3 "production": "warn", 4 "development": "info" 5 }, 6 "persist":"error", 7 "max":2 8}
On server side, initialize plugin in server.js
1 2var loglevel = require('loglevel'); 3var logger = require('loglevel-prefix-persist/server') 4var log = logger(process.env.NODE_ENV, loglevel, logCfg); 5 6 7var app = express(); 8app 9 .use(bodyParser.urlencoded({ extended: false })) 10 .use(bodyParser.json()) 11 12//... 13 14if (log.writer) { 15 // if client log persistence is enabled, this will accept and writes logs coming from client side 16 app.use(log.writer); 17} 18 19
On client side, initialize plugin in client.js entry
1var loglevel = require('loglevel'); 2var logger = require('loglevel-prefix-persist/client'); 3var log = logger('development', loglevel, logCfg); 4
All together (for both client and server)
1 2// namespacing modules 3var log = require('loglevel').getLogger("my/module-name"); 4 5// start logging 6log.debug('Debug will not show') 7log.info('Info will show under development, but not in production','config',logCfg) 8log.warn('Warn will always show') 9log.error('Error will always show')
#Result server
client
#Config
- Default environment is 'development'
- Default log level is 'info'
- Default persistence for server is same as log level
- Default persistence for client is disabled
- If persistence is turned on and max is not set, old files will not be cleaned up
Config examples:
1 2// log level='warn', server persistence only (at 'warn'), log daily forever 3var logCfg = { 4 "level":"warn" 5} 6 7// log level for client+server, no persistence 8var logCfg = { 9 "level": {"server":"info", "client":"warn"}, // regardless of environment 10 "persist":false 11} 12 13// log level for production+development, persist for level='error', max 2 days log 14var logCfg = { 15 "level":{ 16 "production": "warn", 17 "development": "info" 18 }, 19 "persist":"error", 20 "max":2 21} 22 23// cfg for production+developement, client+server 24var logCfg = { 25 "level":{ 26 "production": {"server":"info", "client":"warn"}, 27 "development": "debug" 28 }, 29 "persist":{ 30 "client":"error", // only persist client level='error' 31 "server":true // persist server 'debug' in development, 'info' in production 32 }, 33 "max":2 34} 35 36
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
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