Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Easy to use (config-based) wrapper around winston logger
7
-> debug
6
-> info
5
-> notice
4
-> warning
3
-> error
2
-> crit
1
-> alert
0
-> emerg
npm i @c8/logger
// import logger component
var logger = require('logger')
// Define config options
var config = {
transports: {
console: {
level: ['info', 'debug'],
options: {}
},
file: {
level: ['error', 'crit', 'alert', 'emerg'],
options: {}
}
}
}
// Initialize Logger config
logger.init(config)
// Use logger
logger.debug('This is the debug message')
Console logger options: console.options
File logger options: file.options
In order to use the logger as an Express middleware you should add:
var loggerMiddleware = logger.middleware.Express
server.use(loggerMiddleware.debug)
// or
server.get('/', loggerMiddleware.debug, function (req, res) {
res.status(200)
}
The middleware logger uses the same config you pass in logger.init(/*config*/)
and depending on the log level method you use the middleware with it will be sent to the transport specified in the config.
The middleware can be used globally before any route server.use(loggerMiddleware.debug)
or route specific server.get('/route', loggerMiddleware.debug, function (req, res) {...})
All error logs are pushed using levels error
, crit
, alert
, emerg
and should be defined under the route declaration:
// ^^^ all routes are defined above ^^^
// use 'error' method for error printing
server.use(loggerMiddleware.error)
Logger has a default log messages formatting. There are 2 different use-cases on how the formatting will look like:
logger.debug('log message')
{{timestamp}} {{hostname}} {{logLevel}} {{logMessage}}
logger.debug('log message', new Error('My Log Error'))
{{timestamp}} {{hostname}} {{errorType}}:{{errorMessage}} {{path:line:column}} {{logLevel}} {{logMessage}}
Run the following commands:
npm run test
for unit testsnpm run standard
for StandardJS compilingnpm run coverage
for code coverageMIT Licence © Copyright 2016 C8 MANAGEMENT LIMITED
FAQs
Easy to use (config-based) wrapper around winston logger
The npm package @c8/logger receives a total of 0 weekly downloads. As such, @c8/logger popularity was classified as not popular.
We found that @c8/logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.