spur-common
Version:
Common node library that is implemented through the use of spur-ioc and bluebird promises.
17 lines (11 loc) • 619 B
text/coffeescript
module.exports = (Timer, HTTPPlugin, Logger)->
class HTTPLogging extends HTTPPlugin
start:()->
@timer = new Timer().start()
Logger.info("HTTPService attempting: #{@request.method} #{@request.url}")
end:()=>
duration = @timer.stop()
if @request.error
Logger.error("HTTPService error: #{@request.method} #{@request.url}, timing:#{duration}ms, status:#{@request.response?.status}", @request.error.message)
else if @request.response
Logger.info("HTTPService success: #{@request.method} #{@request.url}, timing:#{duration}ms, status:#{@request.response.status}")