[
https://issues.apache.org/jira/browse/LOG4J2-1705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16383191#comment-16383191
]
Raman Gupta commented on LOG4J2-1705:
-------------------------------------
[~jvz] Mostly good points. Another iteration pushed.
Some questions and comments:
* I haven't touched `CompleteKotlinLogger` yet, as we may end up deleting this
anyway (I think we should, as the user can always get the ExtendedLogger
delegate from `KotlinLogger` anyway).
* For `fun <R> traceExit(message: CharSequence, result: R?): R?`, my approach
allows for the return type to be non-null if the parameter is non-null whereas
your signature always returns a nullable even if the parameter passed in is
non-nullable. However, see comment below about trace methods.
* Right now, args that take a `Supplier` are defined as `() -> Any?` – it's
unclear to me what happens when you return a null value out of a supplier – if
log4j skips the logging entirely, allowing the Supplier to return null might be
a useful capability – the user can use it like an implicit `if(...) \{ log(...)
}`. If that isn't a thing in the underlying implementation, then it should
probably return `Any` instead.
* I've left Throwable? – the methods that don't take a Throwable just delegate
to passing `null: Throwable?` anyway, so that can be a useful shortcut if the
user has a `Throwable?` value.
* For traceEntry and traceExit, I had a TODO in there to clean these up and
now I've done so. I'd like users to just use `runInTrace` which is far simpler
and handles all of the conditions for them. That means I deleted all the
`traceExit` methods entirely, and pared down `traceEntry` to (what I think) is
the minimal needed to get an `EntryMessage`. Unfortunately, `ExtendedLogger`
does not currently have any traceEntry methods that take a lambda for the
message, so I had to create a lambda-accepting method that checks
`isTraceEnabled` before calling the lambda.
> Kotlin wrapper for Log4j 2 API
> ------------------------------
>
> Key: LOG4J2-1705
> URL: https://issues.apache.org/jira/browse/LOG4J2-1705
> Project: Log4j 2
> Issue Type: New Feature
> Components: API
> Reporter: Raman Gupta
> Priority: Major
>
> Similar to LOG4J2-1181 for Scala, provide a Kotlin wrapper for the Log4j 2
> API that makes use of Kotlin features like delegates and string interpolation.
> If there is interest in this, I'd like to contribute a patch.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)