oshai / kotlin-logging

Lightweight Multiplatform logging framework for Kotlin. A convenient and performant logging facade.
Other
2.51k stars 110 forks source link

Fluent Logging: Allow nullable values #402

Closed Zack-Freedman-Thoughtworks closed 2 months ago

Zack-Freedman-Thoughtworks commented 3 months ago

References: https://github.com/oshai/kotlin-logging/issues/400#issuecomment-1964617668

Example:

Example:

logger.atError {
    this.message = "Failed to make a good example: ${throwable.message}."
    this.cause = throwable
    this.payload = mapOf(
        "itemOne" to headers.getNullableThing(),
    )
}

Allows the value in the payload to be nullable. It seems that the code referencing the payloads are are written in Java so it is harder to know if this will lead to a null pointer exception or other troubles with possible loggers but the tests pass.

oshai commented 2 months ago

From code checks I did I think the Java frameworks allow values to be null.

oshai commented 2 months ago

Thanks!