lightbend-labs / scala-logging

Convenient and performant logging library for Scala wrapping SLF4J.
Apache License 2.0
910 stars 130 forks source link

Logging Macro Doesn't Support Scala2 + Scala3 Simultaneously #317

Open Zeimyth opened 2 years ago

Zeimyth commented 2 years ago

I am working in a Scala project that is in the middle of migrating from Scala 2 to Scala 3. We are trying to perform this migration in piecemeal, but the scala-logging library is currently making it difficult to do so.

In theory, there should be a way to implement Scala macros such that both Scala 2 and Scala 3 dependencies can depend on the library and call the macro code (see https://github.com/scalacenter/mix-macros-scala-2-and-3, an example repo put together to demonstrate how to do this). However, when attempting this with the scala-logging library (see https://github.com/Zeimyth/mix-macros-scala-2-and-3/pull/1), the Scala 2 build gets these errors at compile time:

Main.scala:12:14: Unsupported Scala 3 inline macro method info; found in trait com.typesafe.scalalogging.LoggerImpl.
[error]   logger.info("Hello, World!")
[error]              ^
[error] one error found
[error] (app2 / Compile / compileIncremental) Compilation failed

I am not fluent enough in Scala macros (and certainly not in cross-version Scala macro support) to know exactly why the example repo's macro is supported in both Scala versions but the scala-logging one is not. I think it has to do with the way the example repo is defining a single source file that exposes both macros together: https://github.com/scalacenter/mix-macros-scala-2-and-3/blob/develop/testframework/src/main/scala/testframework/package.scala. Perhaps scala-logging needs something like this?

Zeimyth commented 2 years ago

There hasn't been any discussion activity on this issue in the month since I opened it. Is anyone actively working on this issue who could share the status of it? I am trying to dig into the problem still myself in my spare time, but progress has been slow.

seanrohead commented 2 years ago

We are running into the same issue and would like a resolution for this as well