Esempio n. 1
0
 /// <summary>
 /// Fire off the on log event.
 /// </summary>
 /// <param name="logStatement">The log statement that was created.</param>
 private void TriggerOnLog(LogStatement logStatement)
 {
     lock (lockObj) {
         if (onLog != null)
         {
             onLog(this, new LogEventArgs(logStatement));
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Log a debug message to the console / file.
        /// </summary>
        /// <param name="message">The debug message to print.</param>
        public void Debug(string message)
        {
            LogStatement logStatement = new LogStatement(LogStatementType.Debug, message);

            lock (lockObj) {
                History.Add(logStatement);
            }

            LogToUnity(logStatement);
            TriggerOnLog(logStatement);
        }
Esempio n. 3
0
        /// <summary>
        /// Log a debug message to the console / file. Parameters
        /// are inserted into the message using string.format().
        /// </summary>
        /// <param name="message">The debug message to print.</param>
        /// <param name="parameters">The objects to insert into the message.</param>
        public void Debug(string message, params object[] parameters)
        {
            string       fullMessage  = string.Format(message, parameters);
            LogStatement logStatement = new LogStatement(LogStatementType.Debug, fullMessage);

            lock (lockObj) {
                History.Add(logStatement);
            }

            LogToUnity(logStatement);
            TriggerOnLog(logStatement);
        }
Esempio n. 4
0
        /// <summary>
        /// Log an exception to the console / file.
        /// </summary>
        /// <param name="exception">The exception to log.</param>
        public void Error(Exception exception)
        {
            string       exceptionString = exception.ToString();
            LogStatement logStatement    = new LogStatement(LogStatementType.Error, exceptionString);

            lock (lockObj) {
                History.Add(logStatement);
            }

            LogToUnity(logStatement);
            TriggerOnLog(logStatement);
        }
Esempio n. 5
0
 /// <summary>
 /// Log the log statement to the Unity Debug.Log class.
 /// </summary>
 /// <param name="logStatement">The statement to log.</param>
 private void LogToUnity(LogStatement logStatement)
 {
     if (Context.IsCurrentThreadMain())
     {
         LogToUnityHelper(logStatement);
     }
     else
     {
         Context.ExecuteOnMain(() => {
             LogToUnityHelper(logStatement);
         });
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Helper to handle processing which Debug method to call.
        /// </summary>
        /// <param name="logStatement">The log statment to log.</param>
        private void LogToUnityHelper(LogStatement logStatement)
        {
            switch (logStatement.LogType)
            {
            case LogStatementType.Debug:
                UnityEngine.Debug.Log(logStatement.ToString());
                break;

            case LogStatementType.Warning:
                UnityEngine.Debug.LogWarning(logStatement.ToString());
                break;

            case LogStatementType.Error:
            case LogStatementType.Fatal:
                UnityEngine.Debug.LogError(logStatement.ToString());
                break;
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Create a new set of arguments.
 /// </summary>
 /// <param name="logStatement">The statement to pass around.</param>
 public LogEventArgs(LogStatement logStatement)
 {
     LogStatement = logStatement;
 }