Hello there! I’ve noticed that some logs are missing when using tapir + zio-http. Given the following code:
case class Foo(bar: String, baz: Int)
object Foo:
given JsonCodec[Foo] = DeriveJsonCodec.gen
given Schema[Foo] = Schema.derived[Foo]
object TapirHttpServer extends ZIOAppDefault:
val body: PublicEndpoint[Unit, Unit, List[Foo], Any] =
endpoint.get.in("body").out(jsonBody[List[Foo]])
val app: HttpApp[Any, Throwable] =
ZioHttpInterpreter().toHttp(
body.zServerLogic(_ => ZIO.succeed(List(Foo("a", 1), Foo("b", 2), Foo("c", 3))))
)
override def run =
val logConfig =
RequestHandlerMiddlewares.requestLogging(logRequestBody = true, logResponseBody = true)
Server
.serve(app.withDefaultErrorResponse @@ logConfig)
.provide(
ZLayer.succeed(Server.Config.default.port(8080)),
Server.live
).exitCode
when hitting /body
the logs show:
[info] timestamp=2023-07-13T13:43:17.990517Z level=INFO thread=#zio-fiber-41 message="Http request served" location=arara.webhooks.TapirHttpServer.run file=TapirHttpServer.scala line=34 method=GET url=/body status_code=200 request_size=0 duration_ms=210 request=
even though there’s a body, the response
and response_body
annotations are missing. Using only zio-http, the logs are:
[info] timestamp=2023-07-13T13:50:49.275528Z level=INFO thread=#zio-fiber-41 message="Http request served" location=arara.webhooks.ZioHttpServer.app file=ZioHttpServer.scala line=21 method=GET url=/body response_size=61 status_code=200 duration_ms=222 request= response=[{"bar":"a","baz":1},{"bar":"b","baz":2},{"bar":"c","baz":3}] request_size=0
I believe the way I customize the logs is correct, once the request works as expected. Is this a bug?