AAkira / Napier

Logging library for Kotlin Multiplatform
Apache License 2.0
786 stars 34 forks source link

Dev/0.0.3 lambda signatures #9

Closed chris-hatton closed 5 years ago

chris-hatton commented 5 years ago

Hi! Thanks for Napier. This PR provides a feature that no logging framework should be without: lazily evaluated log messages.

Each Napier.x(...) logging function is duplicated to additionally allow String-returning lambdas. When using these signatures, the evaluation of messages is deferred until the required Log-level is confirmed (in Napier.log(...)).

This should be preferred for log messages whose String formatting incurs a significant cost: this can be avoided when in production.

AAkira commented 5 years ago

@chris-hatton Thank you for PR.

This is a nice idea. I think there is probably a better way to do this but I have no idea now.

I'll release this change. I'm sorry if this interface changes.