예제 #1
0
 // Callback to handle Logging calls when Analytics.sendExceptions is enabled.
 // NOTE: stackTrace may not be present on non-Development builds!
 void Callback_HandleLog(string logString, string stackTrace, LogType type)
 {
     if (type == LogType.Log || type == LogType.Warning)
     {
         return; // ignore normal logging
     }
     if (type == LogType.Error || type == LogType.Exception || type == LogType.Assert)
     {
         // Map LogType.Error to "non-fatal" exception analytics hit,
         // and LogType.Assert & LogType.Exception to "fatal" one.
         bool isFatal = (type != LogType.Error);
         gua.cancelHit();
         // Don't send same thing over and over again, exception count
         // happening e.g. in Update() can add up very quickly.
         if (!prevExceptionLogString.Equals(logString) ||
             !prevExceptionStrackTrace.Equals(stackTrace))
         {
             gua.sendExceptionHit("(" + type.ToString() + ")" + logString + ":\n" + stackTrace, isFatal);
         }
         prevExceptionLogString   = logString ?? "";
         prevExceptionStrackTrace = stackTrace ?? "";
     }
 }