Skip to content

Conversation

@pjfanning
Copy link
Member

@pjfanning pjfanning commented Dec 11, 2021

This is far from a full solution to having Scala 3 build working. It does upgrade some tools and libs as a baby step.

Relates to https://issues.apache.org/jira/browse/LOG4J2-3184

Biggest problem for scala 3 is writing something to replace https://github.com/apache/logging-log4j-scala/blob/master/src/main/scala-2.11%2B/org/apache/logging/log4j/scala/LoggerMacro.scala - this type of macro is not supported in scala 3 - the good news is that scala-logging have https://github.com/lightbend/scala-logging/blob/main/src/main/scala-3/com/typesafe/scalalogging/LoggerMacro.scala that could be the way to go

Copy link
Member

@jvz jvz left a comment

Choose a reason for hiding this comment

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

Looks good so far! Let me know when you're finished and we can work on making a release.

@pjfanning
Copy link
Member Author

Thanks for the comments @jvz - I've only covered a fraction of the functions so far - I'll keep tipping away but it could take a while. Scala macros are not something I've worked with much. The tests also rely on scala reflection code that does not seem to work in Scala 3 so I might need to rewrite those too.

@pjfanning
Copy link
Member Author

@jvz I'm wondering about some logger methods and why we don't just call the delegate directly - that using the macro code doesn't seem to add anything in some cases.

For example:

def traceExit(): Unit =
  macro LoggerMacro.traceExit

this could be:

def traceExit(): Unit =
 delegate.traceExit()

@pjfanning pjfanning marked this pull request as draft December 13, 2021 20:10
@jvz
Copy link
Member

jvz commented Dec 21, 2021

Made some minor dependency updates recently. Go ahead and rebase or merge from master.

@pjfanning
Copy link
Member Author

@jvz I've made some progress but could you look at my comment from 10 days ago? Is it ok just to delegate the traceEntry and traceExit calls to wrapped logger instead of getting macros involved? In my head, the only benefit of the macros is to take Scala interpolated strings and convert them to log4j interpolated strings.

@jvz
Copy link
Member

jvz commented Dec 21, 2021

Oh yeah, please, go ahead and make that a delegated method. The point of the macros in the past were to allow for string interpolation to be elided when logging is disabled for that call.

@pjfanning pjfanning changed the title upgrade dependencies to partially suit scala 3 build scala 3 support Dec 21, 2021
@pjfanning
Copy link
Member Author

@jvz is it ok to change the scala 2 build so that traceEntry and traceExit use no macros there either (for consistency)?

@jvz
Copy link
Member

jvz commented Dec 21, 2021

Yes

@pjfanning pjfanning marked this pull request as ready for review December 21, 2021 21:59
@pjfanning
Copy link
Member Author

@jvz could you review this when you get a chance?

Copy link
Member

@jvz jvz left a comment

Choose a reason for hiding this comment

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

This looks great! I like the simplifications you've done, too. Nice to see an easier macro-like system in Scala 3, too. Were there any other changes you think we need, or is this sufficient to work on a new release candidate?

@pjfanning
Copy link
Member Author

@jvz I'm happy to get this merged as is

@jvz jvz merged commit 4efe129 into apache:master Dec 23, 2021
@jvz
Copy link
Member

jvz commented Dec 23, 2021

Thanks so much for the PR! I'll work on a release candidate sometime today (assuming the rest of the build still works as documented).

@pjfanning pjfanning deleted the scala3 branch December 23, 2021 20:50
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.

2 participants