Esempio n. 1
0
        /// <summary>Begins logging.</summary>
        public static void StartLogger()
        {
            if (currentLogger != null)
            {
                Destroy(currentLogger);
            }
            GameObject loggerObject = new GameObject("Performance Logger");

            currentLogger = loggerObject.AddComponent <PerformanceLogger>();
            CurrentState  = LoggerState.Logging;
        }
Esempio n. 2
0
 /// <summary>Ends the logger, dumping to a logfile.</summary>
 /// <param name="path">Full name and path of the logfile to dump to.</param>
 /// <param name="extraInfo">Any extra information to prepend to the logfile.</param>
 /// <param name="async">If the dump process should run in asynchronous mode.</param>
 /// <param name="completionCallback">An optional callback to execute upon completing the log dump.</param>
 public static void EndLogger(string path, string extraInfo = "", bool async = true, Action completionCallback = null)
 {
     if (currentLogger == null)
     {
         Debug.LogError("ERROR: No logger was running");
     }
     else
     {
         CurrentState = LoggerState.Dumping;
         if (async)
         {
             //Ends logger, begins asynchronous dump, completing all main thread only tasks before entering async mode
             currentLogger.completionCallback = completionCallback;
             if (openLogFolder)
             {
                 if (completionCallback == null)
                 {
                     currentLogger.completionCallback = () => ShowLogFolder(path);
                 }
                 else
                 {
                     currentLogger.completionCallback += () => ShowLogFolder(path);
                 }
             }
             currentLogger.GetSystemSpecs();
             Thread dumpThread = new Thread(new ThreadStart(() => currentLogger.DumpLog(path, extraInfo)));
             dumpThread.IsBackground = true;
             dumpThread.Start();
         }
         else
         {
             //Dumps logfile and ends logger
             currentLogger.DumpLog(path, extraInfo);
             completionCallback();
             if (openLogFolder)
             {
                 ShowLogFolder(path);
             }
             Destroy(currentLogger.gameObject);
             currentLogger = null;
         }
     }
 }
Esempio n. 3
0
 private void Update()
 {
     if (currentLogger == null)
     {
         Destroy(this);
     }
     if (CurrentState == LoggerState.Logging)
     {
         LogFrameTime();
     }
     else if (CurrentState == LoggerState.None)
     {
         //Terminates logger once dump is complete
         if (completionCallback != null)
         {
             completionCallback();
         }
         currentLogger = null;
         Destroy(this.gameObject);
     }
 }