What was your use case for "deferred"?
Opened this issue · 2 comments
Hi @frqnck
I intend to use this library to write logs to files in JSON format, then have Fluentd / Fluentbit tail these files for further processing.
I'd be interested in the "deferred" option to avoid writing to a file on disk all throughout script execution (seems cleaner to me to make one big write at the end).
However, the current implementation in AbstractLogger, method __destruct seems to just take all messages (strings), throw away the context, and write a single NOTICE entry in the log.
Why is that? I would have expected the deferred method to just process the backlog of log entries and write() them one by one.
Should you maybe clarify the way it works in the README?
Also, is there any technical reason for the "final" keyword on __destruct in AbstractLogger?
Thanks
Hi @matrey
Sorry for the late reply, you are right currently the __destruct
method is much as you described. Not sure why that is -- probably at the time of implementation I must have needed it that (lazy) way. This clearly could do with being refactored and to process the backlog of entries one by one as rightly suggested. Should be straight forward to do. Please feel free to PR.
It is marked as "final" so it could not be overloaded i.e. impose the abstract implementation to all the logger types -- it is just an API choice.
Thanks for posting this out.