// ---------------------------------------- // // BuglyInit.cs // // Author: // Yeelik, // // Copyright (c) 2015 Bugly, Tencent. All rights reserved. // // ---------------------------------------- // using UnityEngine; using System.Collections; using System.Collections.Generic; public class BuglyInit { /// /// Your Bugly App ID. Every app has a special identifier that allows Bugly to associate error monitoring data with your app. /// Your App ID can be found on the "Setting" page of the app you are trying to monitor. /// /// A real App ID looks like this: 90000xxxx //#if UNITY_IPHONE || UNITY_IOS // private const string BuglyAppID = "YOUR APP ID GOES HERE"; //#elif UNITY_ANDROID // private const string BuglyAppID = "728290c0c0"; //#else // private const string BuglyAppID = ""; //#endif public static void Init () { // Enable the debug log print BuglyAgent.ConfigDebugMode (true); // Config default channel, version, user //BuglyAgent.ConfigDefault (null, null, null, 0); // Config auto report log level, default is LogSeverity.LogError, so the LogError, LogException log will auto report BuglyAgent.ConfigAutoReportLogLevel (LogSeverity.LogWarning); // Config auto quit the application make sure only the first one c# exception log will be report, please don't set TRUE if you do not known what are you doing. //BuglyAgent.ConfigAutoQuitApplication (false); // If you need register Application.RegisterLogCallback(LogCallback), you can replace it with this method to make sure your function is ok. //BuglyAgent.RegisterLogCallback (null); // Init the bugly sdk and enable the c# exception handler. //Unity中的libmono.so进行了信号处理,为了避免处理冲突libBugly.so将关闭信号处理,导致无法上报Native异常(SIGSEGV,SIGABRT,SIGFPE,SIGBUS) //要解决这个问题,你需要在导出的Android项目中,在Activity.onCreate()中初始化Bugly(CrashReport.initCrashReport()) //BuglyAgent.InitWithAppId (BuglyAppID); // TODO Required. If you do not need call 'InitWithAppId(string)' to initialize the sdk(may be you has initialized the sdk it associated Android or iOS project), // please call this method to enable c# exception handler only. BuglyAgent.EnableExceptionHandler (); // TODO NOT Required. If you need to report extra data with exception, you can set the extra handler //BuglyAgent.SetLogCallbackExtrasHandler (MyLogCallbackExtrasHandler); } // Extra data handler to packet data and report them with exception. // Please do not do hard work in this handler static Dictionary MyLogCallbackExtrasHandler () { // TODO Test log, please do not copy it BuglyAgent.PrintLog (LogSeverity.Log, "extra handler"); // TODO Sample code, please do not copy it Dictionary extras = new Dictionary (); extras.Add ("ScreenSolution", string.Format ("{0}x{1}", Screen.width, Screen.height)); extras.Add ("deviceModel", SystemInfo.deviceModel); extras.Add ("deviceName", SystemInfo.deviceName); extras.Add ("deviceType", SystemInfo.deviceType.ToString ()); extras.Add ("deviceUId", SystemInfo.deviceUniqueIdentifier); extras.Add ("gDId", string.Format ("{0}", SystemInfo.graphicsDeviceID)); extras.Add ("gDName", SystemInfo.graphicsDeviceName); extras.Add ("gDVdr", SystemInfo.graphicsDeviceVendor); extras.Add ("gDVer", SystemInfo.graphicsDeviceVersion); extras.Add ("gDVdrID", string.Format ("{0}", SystemInfo.graphicsDeviceVendorID)); extras.Add ("graphicsMemorySize", string.Format ("{0}", SystemInfo.graphicsMemorySize)); extras.Add ("systemMemorySize", string.Format ("{0}", SystemInfo.systemMemorySize)); extras.Add ("UnityVersion", Application.unityVersion); BuglyAgent.PrintLog (LogSeverity.LogInfo, "Package extra data"); return extras; } }