-
Notifications
You must be signed in to change notification settings - Fork 386
Add logging to MultiplatformSettingsStorage #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Breaks the dependency cycle between the storage class and the logger so that the storage implementation can also contribute to logs.
36594e0 to
82b5df6
Compare
shared/src/commonMain/kotlin/org/jetbrains/kotlinconf/utils/Logger.kt
Outdated
Show resolved
Hide resolved
| buffer.forEach { entry -> | ||
| realLogger.log(entry.tag) { entry.message } | ||
| } | ||
| buffer.clear() | ||
| delegate = realLogger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may lose some messages here, both between forEach and clear, and between clear and setting delegate.
If adding a lock is undesirable, I'd suggest at least draining the buffer again after setting the delegate.
Another improvement would be to remember the last dumped message, cleaning the buffer only until that point, and again re-dumping the rest after a delegate is assigned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid a lock on the happy path of logging into a delegate that's already set.
But I now added locking for working with the buffer now. Any of those interactions should only happen during app launch and never past that.
ce0b9ac to
8930936
Compare
|
I cannot get rid of the feeling, that we can resolve settings <-> logging dependency in some other way, without overcomplicating logging. |
|
@kropp I'd love to have a cleaner solution as well, but I can't think of anything obviously better. Some alternatives that I see would be:
|
Breaks the dependency cycle between the storage class and the logger so that the storage implementation can also contribute to logs.
Fixes #544