KLoggingEventBuilder accept nullable values in payload
Zack-Freedman-Thoughtworks opened this issue · 4 comments
Hello! Is it possible to modify KLoggingEventBuilder to accept nullable values? This would allow us to avoid null-checks in the code we are adding logs to.
Example:
logger.atError {
this.message = "Failed to make a good example: ${throwable.message}."
this.cause = throwable
this.payload = mapOf(
"itemOne" to headers.getNullableThing(),
)
}
Thank you for reporting an issue. See the wiki for documentation and slack for questions.
yes. would you like to create a PR?
@oshai Created a PR here. Would you please help me validate that it doesn't lead to a null-pointer? I'm not too knowledgable in how this library integrates with the other libraries as a whole.
Sadly as these are public classes, I'm not sure if these are backwards compatible changes. I also happen to know data classes don't fair well with backwards compatible changes either. See here
I think the change is safe (both NPE and backward compatibility).