holgerbrandl / kalasim

Discrete Event Simulator
https://www.kalasim.org/
MIT License
69 stars 10 forks source link

Add a standard logging library #40

Closed pambrose closed 2 years ago

pambrose commented 2 years ago

I have been using https://github.com/MicroUtils/kotlin-logging for years and it works great.

The only thing required to enable it for a given class is to make its companion object inherit from KLogging:

companion object : KLogging()

You then get a local logger value and can add as much logging instrumentation as you want and not worry about overhead because the actions are all lambdas, which are not evaluated if the call level does not warrant it.

Have a look and see what you think.

holgerbrandl commented 2 years ago

I know the microutils library and use it in other projects. I also tried to adopt regular JVM logging here but failed yet. The reason is that since major components such as resources, queues, components are often not sub-classed, it becomes very hard to fine-tune the logging level.

With the event system, the user can subscribe to whatever he/she needs.

Also, all major logging frameworks have only very limited support for structured logging. In contrast with the events, there is a nice typed API to deal with simulation events. To me, the events are the true workhorse to study simulation dynamics (in conjunction with the various timeline attributes)

Feel welcome if you have some ideas about how to establish more standardized logging. Maybe we could also find a way to add a EventListener that establishes a bridge into the regular logging world?

holgerbrandl commented 2 years ago

I've tried to put some details and example into the docs. Feel welcome to reopen the ticket if you think that this could/should be solved differently.