-
Notifications
You must be signed in to change notification settings - Fork 294
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
Enhancement: Logger that can be flushed? to better cooperate with CocoaLumberjack #171
Comments
I don't think we should add For crashes, it wouldn't help either because we can't know when we'll crash so we can't just flush before the crash. If the app terminates in a controlled manner, then CocoaLumberjack flushes automatically. If you really want this functionality, you could use the metadata as an escape hatch. If you call extension Logger {
public func flushNow() {
var dummy = self
dummy[metadataKey: "cocoa-lumberjack-flushnow"] = nil // catch this in your `LogHandler` and call Lumberjack's flushNow
}
} |
I use
Log
andLogger
API for general logging needs in my custom packages on Linux and iOS. Everything works great.On iOS I initialize the
Log.logger
(for historical reasons and cooperation with legacy code) with my custom implementation of https://github.com/CocoaLumberjack/CocoaLumberjack basedLogger
implementation.Also works great. Except for one thing. CocoaLumberjack is high perf and highly async, and when my app crashes controllably, the last few most important log statements are lost.
For that CocoaLumberjack provides a method
DDLog.flushLog
https://github.com/CocoaLumberjack/CocoaLumberjack/blob/832adf8139ee8b9810683a110a2318a9ea225a5a/Sources/CocoaLumberjack/include/CocoaLumberjack/DDLog.h#L367.I would like to open a PR to propose addition of
Logger.flush()
andLog.flush()
methods that would allow my app to invoke these methods and propagate them down in order to make sure logging is flushed in cases where app is terminated in a controlled manner.What do you think? How you achieve the same?
The text was updated successfully, but these errors were encountered: