GitHub user daniel-morgenstern created a discussion: Support Kotlin’s "Unused 
Return Value" Warnings for improved developer experience


Kotlin provides a feature that allows APIs to indicate that a return value 
**must be used**. When this is enabled via an annotation, the Kotlin compiler 
can emit warnings if a caller ignores the return value.

Applying this annotation in Log4j could help prevent subtle logging mistakes. 
For example, consider the following code (missing `.log()`):

```kotlin
log.atInfo().setMessage("Some sample message")
```

By marking the return value of all builder methods as “must be used,” the 
Kotlin compiler could emit warnings for incomplete fluent logging statements. 
This would make such issues detectable at compile time and improve the overall 
developer experience for Kotlin users working with fluent Log4j APIs.

You can get more information about this here: 
https://kotlinlang.org/docs/unused-return-value-checker.html

GitHub link: https://github.com/apache/logging-log4j2/discussions/4027

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to