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

Add direct log4cats integration #286

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

igor-ramazanov
Copy link

@igor-ramazanov igor-ramazanov commented Feb 22, 2025

Direct log4cats integration without slf4j middleman.
Allows using Woof with the new http4s-1.x as it requires LoggerFactory[F] for EmberClientBuilder and EmberServerBuilder.

Works on JVM.

On JS test needs to be fixed - the LogInfo is a little wonky there.

Couldn't run Native locally, apparently it hangs on linking.

Failed to run mdoc too.

@igor-ramazanov igor-ramazanov marked this pull request as ready for review February 22, 2025 13:34
@igor-ramazanov igor-ramazanov changed the title Add log4cats integration Add direct log4cats integration Feb 22, 2025
val callingMethodIndex = stacktraceElements.size - lastIndex
val callingMethod = stacktraceElements(callingMethodIndex)
val fileName =
(callingMethod.getClassName.replace('.', '/') + ".scala").split("\\/").takeRight(1).mkString
Copy link
Author

@igor-ramazanov igor-ramazanov Feb 22, 2025

Choose a reason for hiding this comment

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

On JS it returns something like (<jscode>.scala:96229), not sure how to get a source file / line number.

Copy link
Author

Choose a reason for hiding this comment

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

log4cats doesn't support sourcecode info, but it's a requirement for woof.

Perhaps, I could create a variant of Logger#doLog which doesn't require LogInfo to facilitate log4cats integration.

Comment on lines 46 to 50
override def isErrorEnabled: F[Boolean] = Applicative[F].pure(true)
override def isWarnEnabled: F[Boolean] = Applicative[F].pure(true)
override def isInfoEnabled: F[Boolean] = Applicative[F].pure(true)
override def isDebugEnabled: F[Boolean] = Applicative[F].pure(true)
override def isTraceEnabled: F[Boolean] = Applicative[F].pure(true)
Copy link
Author

Choose a reason for hiding this comment

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

Not sure if it's a problem, but log level filtering works.

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

Successfully merging this pull request may close these issues.

1 participant