Skip to content

Instantly share code, notes, and snippets.

@adamw
Created February 15, 2018 15:39
Show Gist options
  • Save adamw/1e8989ac56dda8b0e163cf39f9c7cf70 to your computer and use it in GitHub Desktop.
Save adamw/1e8989ac56dda8b0e163cf39f9c7cf70 to your computer and use it in GitHub Desktop.
val logDuration: Directive0 = extractRequestContext.flatMap { ctx =>
val start = System.currentTimeMillis()
mapResponse { resp =>
val took = System.currentTimeMillis() - start
logger.info(s"[${resp.status.intValue()}] ${ctx.request.method.name} " +
s"${ctx.request.uri} took: ${d}ms")
resp
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment