-
Notifications
You must be signed in to change notification settings - Fork 8
Logging in Pocket
We use a central Log class to abstract our logging implementation detail.
Log has a number of class functions that you can use to send events locally, to Sentry and other services while maintaining an agnostic interface in code.
You can call level-specific logging functions.
e.g. Log.error(someObject, [...]
Or you can call a general logging function and pass a Log Level with it.
e.g. Log.log(someObject, level: .error, [...]
Non-error events serious enough to be logged to the backend should be captured:
e.g. Log.capture(message: "Tried to do something without the necessary prerequisites")
Similarly we can capture errors with Log.capture(error:[...]
e.g. Log.capture(error: someErrorObject)
We use Sentry for our remote logging service. Sentry allows us to add breadcrumbs to give context to any issues that follow.
e.g. Log.breadcrumb(category: "Some identifier that you can search in Sentry", level: .warning, message: "Something very strange happened, if we hit an error later this might be important.")
We have several levels of logging that we can filter for to reduce noise on our backend services.
- verbose: Highly detailed events that would be useful in debugging but much too long for general reporting.
- debug: Behavioural information that may be useful when debugging but would be too noisy for general reporting.
- info: General notes while the app is running that add useful context to more serious events.
- warning: Something unexpected or undesirable happened, we can continue without issue.
- error: Something unexpected or undesirable happened, we can continue but this is serious enough to look into.
- fatal: An unrecoverable error has occurred and we need to kill the app to preserve user data or avoid corrupted state.