Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expunge all unsafe logging #6645

Merged
merged 12 commits into from
Jun 2, 2023
Merged

Conversation

armanbilge
Copy link
Member

This starts as a forward merge of #6614.

Then 8ee8295 goes crazy and tries to fixup all the unsafe logging by adding LoggerFactory constraints as needed. This ... was a bit messy.

Inline comments incoming.

Comment on lines -89 to +92
val cl: Option[`Content-Length`] = entity.length match {
case Some(l) =>
`Content-Length`
.fromLong(l)
.fold(
_ => {
Message.logger.warn(s"Attempt to provide a negative content length of $l")
None
},
Some(_),
)
case None => None
}
val cl: Option[`Content-Length`] = entity.length.flatMap(
`Content-Length`
.fromLong(_)
.toOption
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't log in this method unless we make .withEntity return a result in F[_] ... which seems like terrible ergonomics. So I just removed it.

Comment on lines -28 to -30
@deprecated("Obsolete. Not implemented by any backends.", "0.23.12")
object PushSupport {
private[this] val logger = getLogger
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than deal with this, since it was deprecated I just tossed it.

Comment on lines -40 to -43
@deprecated(
"""Deficient. See https://github.com/http4s/http4s/security/advisories/GHSA-52cf-226f-rhr6.""",
"0.21.27",
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all the deprecated CORS stuff so I wouldn't have to rework its logging.

Comment on lines -323 to +89
def apply[F[_]: Applicative, G[_]](http: Http[F, G]): Http[F, G] = {
def apply[F[_]: Applicative, G[_]: Applicative: LoggerFactory](
http: Http[F, G]
): G[Http[F, G]] = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we get into trouble. To log in this method (see below) we have to return the result in an effect now. Maybe this is ok, but it caused extensive refactoring of the CORS test suite.

@@ -82,13 +82,13 @@ class ResourceServiceBuilder[F[_]] private (

def withBufferSize(bufferSize: Int): ResourceServiceBuilder[F] = copy(bufferSize = bufferSize)

def toRoutes(implicit F: Async[F]): HttpRoutes[F] = {
def toRoutes(implicit F: Async[F]): F[HttpRoutes[F]] = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another signature change here, that caused the test suite to need major refactoring. We could, also, just not log ...

@mergify mergify bot added the docs Relates to our website or tutorials label Aug 27, 2022
@armanbilge
Copy link
Member Author

armanbilge commented Sep 14, 2022

Ouch 😂

Conflicting files
build.sbt
circe/src/main/scala/org/http4s/circe/middleware/JsonDebugErrorHandler.scala
client-testkit/jvm/src/main/scala/org/http4s/client/testkit/scaffold/HandlersToNettyAdapter.scala
client-testkit/jvm/src/main/scala/org/http4s/client/testkit/scaffold/NettyTestServer.scala
client/shared/src/main/scala/org/http4s/client/middleware/Logger.scala
client/shared/src/main/scala/org/http4s/client/middleware/RequestLogger.scala
client/shared/src/main/scala/org/http4s/client/middleware/ResponseLogger.scala
client/shared/src/main/scala/org/http4s/client/middleware/Retry.scala
core/shared/src/main/scala/org/http4s/Message.scala
core/shared/src/main/scala/org/http4s/StaticFile.scala
core/shared/src/main/scala/org/http4s/internal/package.scala
ember-client/shared/src/main/scala/org/http4s/ember/client/EmberClientBuilder.scala
ember-server/shared/src/main/scala/org/http4s/ember/server/EmberServerBuilder.scala
project/Http4sPlugin.scala
server/shared/src/main/scala/org/http4s/server/Server.scala
server/shared/src/main/scala/org/http4s/server/middleware/CORS.scala
server/shared/src/main/scala/org/http4s/server/middleware/GZip.scala
server/shared/src/main/scala/org/http4s/server/middleware/HttpsRedirect.scala
server/shared/src/main/scala/org/http4s/server/middleware/Jsonp.scala
server/shared/src/main/scala/org/http4s/server/middleware/Logger.scala
server/shared/src/main/scala/org/http4s/server/middleware/PushSupport.scala
server/shared/src/main/scala/org/http4s/server/middleware/RequestLogger.scala
server/shared/src/main/scala/org/http4s/server/middleware/ResponseLogger.scala
server/shared/src/main/scala/org/http4s/server/package.scala
server/shared/src/main/scala/org/http4s/server/staticcontent/FileService.scala 

@iRevive
Copy link
Contributor

iRevive commented Sep 15, 2022

If I get it right, would it be finally possible to use http4s without bringing slf4j/logback in the classpath?

Blaze still depends on the logabck, but ember does not.

@armanbilge
Copy link
Member Author

Yes, exactly. No more slf4j dependency.

@TonioGela
Copy link

Any updates? That's a definitively useful feature to merge.

@armanbilge
Copy link
Member Author

I can't merge my own PR, but if someone new champions this effort and fix the conflicts I can approve and merge 😜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ember server: don't include log4cats-slf4j
3 participants