LighthouseGames / KmLogging

Kotlin multiplatform logging. High performance, composable and simple to use.
Apache License 2.0
84 stars 13 forks source link

Changes in KmLog.kt for more structurized API #11

Closed InsanusMokrassar closed 2 years ago

ellsworthrw commented 2 years ago

What are your goals or reasons for the request to change the API?

This PR causes considerable overhead in each logging request especially during release builds where you might have disabled logging.

InsanusMokrassar commented 2 years ago

Previous API has several different versions of the same functions. Currently it looks like more structurised (i is calling the same info fun, all the info functions call base (open) info function which can be easily changed in extenders).

Besides, currently for any variant with msg callback there is its analog with String msg

Besides, now it is possible to use API like logger.v("message") instead logger.v { "message" } which in my opinion is better variant. Anyway, with these changes we will have choice what to use - callback or just string

ellsworthrw commented 2 years ago

Using lambdas provides significant performance advantages. If you disable logging in release builds then the string formatting is never computed. Also, the requested changes results in several function call overhead even when logging is disabled. When you have logging disabled the current implementation cost of a logging call is simply evaluating an if condition on a boolean.