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.
bunyan-decorator
Advanced tools
**bunyan-decorator** enables you to log the result of functions that return a promise or a value.
#bunyan-decorator
bunyan-decorator enables you to log the result of functions that return a promise or a value.
npm install bunyan-decorator
const bunyan = require('bunyan');
const bunyand = require ('./bunyan-decorator');
const l = new Logger(bunyan.createLogger({
name: 'my-app'
}));
const log = l.log;
class MyClass {
// Decorator your class method to log it
@log(Level.info)
searchById(id) {
return MySearchService.byId(id);
}
}
Extractors enable you to modify the result logged by the bunyan decorator
class MyClass {
// This extractor will transform the result nil, thus not return value is logged
@log(Level.info, { extractor: result => {} })
searchById(id) {
return MySearchService.byId(id);
}
}
Note all log records include all default bunyan property as well as the class name, the class method, the elapsed time, and the result (unless an extractor is used).
02:12:41.894Z INFO my-app: SchoolsService.all(...) (module=SchoolsService, method=all(...), elapsedTime=428.553181)
result: [
{
"id": "sampleschoolid1",
"location": {
"geo": {
"lat": -1,
"lon": -1
},
"address": {
"street": "10 street rd",
"city": "littleton",
"state": "ma",
"zip": "01146"
}
},
"type": "school",
"name": "sampleschoolid1",
"district": {
"id": "district-1",
"name": "District One",
"type": "district"
},
"group": {
"name": "School Group One"
},
"created": "2017-02-16T13:36:01.781Z"
}
]
"name":"my-app","hostname":"Carmines-MacBook-Pro-7.local","pid":58820,"level":30,"module":"ExpressServer","method":"listen","msg":"up
and running in development @: Carmines-MacBook-Pro-7.local on port: 3003}","time":"2017-02-24T02:15:38.065Z","v":0}
{"name":"ecl-registration","hostname":"Carmines-MacBook-Pro-7.local","pid":58820,"level":30,"module":"SchoolsService","method":"all(...)","elaps
edTime":404.09158199999996,"result":[{"id":"sampleschoolid1","location":{"geo":{"lat":-1,"lon":-1},"address":{"street":"10 street rd","city":"li
ttleton","state":"ma","zip":"01146"}},"type":"school","name":"sampleschoolid1","district":{"id":"district-1","name":"District One","type":"distr
ict"},"group":{"name":"School Group One"},"created":"2017-02-16T13:36:01.781Z"}],"msg":"SchoolsService.all(...)","time":"2017-02-24T02:15:41.487
Z","v":0}
{"name":"ecl-registration","hostname":"Carmines-MacBook-Pro-7.local","pid":58820,"level":30,"module":"Controller","method":"all(...)","elapsedTi
me":410.745346,"msg":"Controller.all(...)","time":"2017-02-24T02:15:41.494Z","v":0}
MIT
FAQs
**bunyan-decorator** enables you to log the result of functions that return a promise or a value.
The npm package bunyan-decorator receives a total of 1 weekly downloads. As such, bunyan-decorator popularity was classified as not popular.
We found that bunyan-decorator 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
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.