bunyan-decorator
bunyan-decorator enables you to log the result of functions that return a promise or a value.
Install
npm install bunyan-decorator
Usage
const bunyan = ;const bunyand = ; const l = bunyan; const log = llog; // Decorator your class method to log it @ { return MySearchService; }
Extractors
Extractors enable you to modify the result logged by the bunyan decorator
// This extractor will transform the result nil, thus not return value is logged @ { return MySearchService; }
Example log record
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).
Pretty
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"
}
]
Raw
"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}
License
MIT