Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. /*Custom logger
  2. This was only an experiment.
  3. I recommend koa-logger npm package
  4. @phonnz
  5. */
  6.  
  7. var requestTime = function(){
  8.  
  9. return function*(next){
  10. var start = new Date;
  11. yield next
  12. if(this.body === 'Not Found') console.log(this.body)
  13. var ms = new Date - start;
  14. console.log(this.request.method, this.request.url, ms, 'ms', this.status)
  15.  
  16.  
  17. }
  18. }
  19.  
  20. app.use(requestTime())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement