Logging before the default log store is accessed results in dropped messages
NickEntin opened this issue · 2 comments
The default log store get lazily created the first time you access the defaultLogStore
property. If you follow the one-line setup approach, this happens immediately since we access the default log store in order to create the bug reporter. If you don't use this setup, however, instead opting to create the bug reporter later, calling log(...)
will send the message nowhere (or really will send the message to other log observers you've added, but not the default log store).
I think the expected behavior would be to create the default log store the first time log(...)
is called if it doesn't already exist.
I'm not sure we should autocreate the default log store – if a team does not want to utilize the default store, should we make them?
I think the fact that the log distributor exposes a defaultLogStore
implies that there will be some default log store (i.e. if you don't explicitly provide one, we'll create it for you). Perhaps it's reasonable to use the distributor without a log store, but in that case we'd probably want to change the API to make it clear the default log store may not exist.
Right now the getter for defaultLogStore
changes behavior, which seems like something we should definitely avoid.
log("Hello world") // This goes nowhere.
_ = ARKLogDistributor.default().defaultLogStore
log("Hello world") // This goes to the log store.
At the very least, I think we should autocreate the default log store when you call log(...)
when there are no other log observers, so the logs have somewhere to go. But the side-effecty getter still seems problematic.
What do you think about doing a two part change:
- Update
-[ARKLogDistributor _logMessage_inLogDistributingQueue:]
to create the default log store if it doesn't already exist in a new patch release. - File an issue to investigate updating
ARKLogDistributor
's API to better support not having a default log store, which would be for the next major release of CoreAardvark.