Logging Errors and Info Messages

Logging Errors and Info Messages

When you want visibility into something instantaneous that happens in your application rather than a moment, you can send info or error messages to Embrace.io for insight into what was happening to the user. These messages will contain diagnostic information, the current thread’s stack trace, and custom properties. Error messages also allow the screenshot functionality so that you can see what the device was displaying at the moment of the error.

Logging Messages

Error messages (including Handled Exceptions) are triggered with a call to logErrorMessage:screenshot:properties:, with the same parameters as the info logs and an additional flag for whether or not you’d like a screenshot to be taken.

Info messages can be sent with a call to logInfoMessage:properties:, where the message is a string that can be searched for later in the web dashboard, and properties is an optional dictionary of (maximum 10) properties.

Objective-C

// Log an error message
NSString *error = @"checkout_error";
[[Embrace sharedInstance] logErrorMessage:logMessage screenshot:YES properties:nil];

// Log an info message
NSString *info = @"something_happened";
[[Embrace sharedInstance] logInfoMessage:info properties:@{@"screen": @"checkout"}];

Swift

// Log an error message
Embrace.sharedInstance().logErrorMessage("something_bad", screenshot: true, properties: [:])

// Log an info message
Embrace.sharedInstance().logInfoMessage("something_happened", properties: ["error": "not_found"])

##