miracle-messages / mm-ios-mobile

3 stars 1 forks source link

Added Crashlytics: #7

Closed shobhitpuri closed 7 years ago

shobhitpuri commented 7 years ago
  • Added new logging mechanism to log only to console in debug mode and to Crashlytics in release mode.
  • Added mechanism to allow to force log important non-fatal errors to Crashlytics.
  • Associated a user to Crashlytics logs. This makes it easier to know the user who is experiencing issues.
  • Updated Crashlytics project the app was pointing to.

Usage: 1- For usual .info logs:

// This will log INFO messages by default.
Logger.log("Message")

2- Define specific log level:

// This  error log will NOT force log to crashlytics but is still cached as one of the log lines for crashlytics. So in case a crash happens or a non-fatal error is forcibly send to crashlytics, these logs would still appear on the crashlytics dashboard along with the exception stacktrace.
Logger.log(level: Level.error, "Some error happened.")

3- Force send the non-fatal log to crashlytics. We should use them wisely since for each user session crashlytics only keeps last 8 non fatals. More here: https://docs.fabric.io/apple/crashlytics/logged-errors.html We can log NSErrors directly like:

Logger.forceLog(NSError)

and we can also have custom errors which are important enough to be notified to crashlytics:

Logger.forceLog(CustomError.loginError(error.localizedDescription))

For this one, you might need to toggle to keys to see the error code and error message for this kind of forced exceptions: Keys vs Logs