koa-log-requests
Customizable Koa middleware for logging incoming requests. Outputs method, path, response status, time spent and request body.
Installation
$ npm install koa-log-requests --save
Usage
var koa = ;var requests = ; var app = ; app;app; app;
Sample:
-> 2016-05-26T18:19:29.551Z method=POST path=/test/rvs/inapp status=200 time=24ms body={"username":"fortino@ooyala.com","appstore":"roku","sku":"aaaaaaaaaa","receipt":"5AB3663A-AA82-4007-A079-A5DA011E6707"}
<- 2016-05-26T18:19:29.575Z method=POST path=/test/rvs/inapp status=200 time=24ms body={"error":{"message":"Invalid signature","code":401,"type":"Invalid_Signature_"},"success":false}
Options
There are few options, that you can customize:
var requests = ; requestsindent = 2; // insert N spaces at the beginningrequestsformat = ':date :method :path status=:status time=:time body=:body data=:custom'; // format of outputrequestsfilter = 'password' 'password_confirmation'; // filter out these keys from request bodyrequests{ return 'something'}; //print any information that you want
License
koa-log-requests is released under the MIT license.