Logging
LogDog offers 3 different ways to handle logs. All types will appear immediately in the LogDog Dashboard.
- LogDogLogger (recommended)
- LogDog log functions like LogDog.i()
- Classical logging via print
The recommended way to log is via the LogDogLogger. This enables the richest logging experience and aligns with Apple's best practices by relying on the official Logger().
let logger = LogDogLogger(subsystem: "com.example.app", category: "test")
logger.i("Info via Logger")
logger.d("Debug via Logger")
logger.w("Warning via Logger")
logger.e("Error via Logger")
Next up is logging via the builtin helper functions:
LogDog.i("Sample Info Log")
LogDog.d("Sample Debug Log")
LogDog.w("Sample Warning Log")
LogDog.e("Sample Error Log")
Supported but not recommended is logging via the classical print.
This can be enabled in the LogDogConfig via prints: true
. If enabled it will catch all prints within an application.
print("Some Log")
If it is a requirement to catch the logs of older third-party dependencies it's fine to use it. It comes with the downside of not delivering useful metadata such as file or line where it was printed.
Log Storage
By default LogDog will store 50 MB of logs on your device. If this amount is exceeded the 1000 oldest logs will be deleted.
To change this limit please call setDBMaxSize()
.
One more way to delete logs is via the debug window using the "Delete Logs" button.
LogDog.setDBMaxSize(sizeInBytes: 1000 * 1000 * 10) // Set size to 10 MB
Logs size is checked on every start of the application.