GUACrashObserver
Set additional log data reporting for crashes
[MSDK & Player Network SDK] When the program crashes, additional custom data may need to be reported to the CrashSight platform along with the crash log. This will allow users to better locate the cause of the crash. The reported data can be found in the CrashSight platform under Trace Log > Attachment Information. For more information, see MSDK document.
For these two files, Android and iOS use different naming conventions.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function Definition
- Unity
- Unreal Engine
event OnStringRetEventHandler<GUABaseResult> CrashBaseRetEvents;
class GUA_EXTERN GUACrashObserver
{
public:
virtual ~GUACrashObserver(){};
// virtual long OnCrashExtraDataNotify(const GUACrashRet &crash_ret){
// return 0;
// };
virtual const char* OnCrashExtraMessageNotify(){
return NULL;
};
};
Code Sample
- Unity
- Unreal Engine
// Initialize
UnionAdapterAPI.GetCrashService().SetCrashCallback();
// Add callbacks
UnionAdapterAPI.GetCrashService().CrashBaseRetEvents += OnCrashBaseResult;
// Remove callbacks
UnionAdapterAPI.GetCrashService().CrashBaseRetEvents -= OnCrashBaseResult;
// CrashBaseRetEvents callback
private string OnCrashBaseResult(GUABaseResult baseRet)
{
// this is not unity ui process, don't do anything about unity
return "this is Unity extra data when crash happened.";
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUACrashObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnCrashExtraMessageNotify
class FGUACrashObserver : public GUA_NAMESPACE::GUACrashObserver
{
public:
static FGUACrashObserver Instance;
public:
const char* OnCrashExtraMessageNotify()
{
char str[] = "this is extra message.";
char *retValue = SAFE_MALLOC(strlen(str) + 1, char);
strcpy(retValue, str);
return retValue;
}
};
FGUACrashObserver FGUACrashObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUACrashService::SetCrashObserver(&FGUACrashObserver::Instance);