Skip to content

Instantly share code, notes, and snippets.

@adamw
Last active January 7, 2020 09:26
Show Gist options
  • Save adamw/b091f96ed8074011e120224e8dee1aec to your computer and use it in GitHub Desktop.
Save adamw/b091f96ed8074011e120224e8dee1aec to your computer and use it in GitHub Desktop.
def timeRequest(request: HttpRequest): Try[RouteResult] => Unit = {
val start = System.currentTimeMillis()
{
case Success(Complete(resp)) =>
val d = System.currentTimeMillis() - start
logger.info(s"[${resp.status.intValue()}] ${request.method.name} " +
s"${request.uri} took: ${d}ms")
case Success(Rejected(_)) =>
case Failure(_) =>
}
}
val routes: Route =
aroundRequest(timeRequest) {
path("...") {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment