コード例 #1
0
ファイル: KGFDebugFile.cs プロジェクト: manboygames/capsa
 /// <summary>
 /// look into KGFIDebug documentation for further information
 /// </summary>
 public void Log(KGFeDebugLevel theLevel, string theCategory, string theMessage, string theStackTrace, MonoBehaviour theObject)
 {
             #if UNITY_WEBPLAYER
     return;
             #else
     try
     {
         using (var file = new StreamWriter(itsDataDebugFile.itsFilePath, true, Encoding.ASCII))
         {
             if (theObject != null)
             {
                 file.WriteLine("{0}{6}{1}{6}{2}{6}{3}{6}{4}{6}{5}", DateTime.Now.ToString(), theLevel, theCategory, theMessage, theObject.name, theStackTrace, itsDataDebugFile.itsSeparator);
             }
             else
             {
                 file.WriteLine("{0}{6}{1}{6}{2}{6}{3}{6}{4}{6}{5}", DateTime.Now.ToString(), theLevel, theCategory, theMessage, string.Empty, theStackTrace, itsDataDebugFile.itsSeparator);
             }
         }
     }
     catch (Exception e)
     {
         Debug.LogError("couldn't write to file " + itsDataDebugFile.itsFilePath + ". " + e.Message);
     }
             #endif
 }
コード例 #2
0
 /// <summary>
 /// creates a KGFDebugLog instance with no reference to a MonoBehaviour game object
 /// </summary>
 /// <param name="theLevel">the log level of this log entry</param>
 /// <param name="theCategory">the category of this log entry</param>
 /// <param name="theMessage">the message of this log entry</param>
 /// <param name="theStackTrace">the stack trace of this log entry</param>
 /// <param name="theObject">the game object referenced to this log entry</param>
 public KGFDebugLog(KGFeDebugLevel theLevel, string theCategory, string theMessage, string theStackTrace)
 {
     itsLevel      = theLevel;
     itsCategory   = theCategory;
     itsMessage    = theMessage;
     itsLogTime    = DateTime.Now;
     itsStackTrace = theStackTrace;
     itsObject     = null;
 }
コード例 #3
0
 /// <summary>
 /// look into KGFIDebug documentation for further information
 /// </summary>
 public void Log(KGFeDebugLevel theLevel, string theCategory, string theMessage, string theStackTrace, MonoBehaviour theObject)
 {
     if (theObject != null)
     {
         Debug.Log(string.Format("{0} {1} {5} {2}{5}{3}{5}{4}", theLevel, theCategory, theMessage, theObject.name, theStackTrace, Environment.NewLine));
     }
     else
     {
         Debug.Log(string.Format("{0} {1} {4}{2}{4}{3}", theLevel, theCategory, theMessage, theStackTrace, Environment.NewLine));
     }
 }
コード例 #4
0
    /// <summary>
    /// sends the log command to all registered loggers
    /// </summary>
    /// <param name="theLevel">level of the log message</param>
    /// <param name="theCategory">category of the log message</param>
    /// <param name="theMessage">message of the log entry</param>
    /// <param name="theObject">gameObject referenced to this log entry</param>
    private static void Log(KGFeDebugLevel theLevel, string theCategory, string theMessage, MonoBehaviour theObject)
    {
        CheckInstance();

        if (itsInstance != null)
        {
            StringBuilder aStackString = new StringBuilder();

            // only create the stack trace if the level of this message is high enough
            if (theLevel >= itsInstance.itsDataModuleDebugger.itsMinimumStackTraceLevel)
            {
                // create the stack trace
                StackTrace aStackTrace = new StackTrace(true);

                // remove the first two frames because of the internam method calls
                for (int i = 2; i < aStackTrace.FrameCount; i++)
                {
                    aStackString.Append(aStackTrace.GetFrames()[i].ToString());
                    aStackString.Append(Environment.NewLine);
                }
            }

            KGFDebugLog aLog = new KGFDebugLog(theLevel, theCategory, theMessage, aStackString.ToString(), theObject);

            if (itsCachedLogs != null)
            {
                itsCachedLogs.Add(aLog);
            }

            // send the message to all registered implementations
            foreach (KGFIDebug aLogger in itsRegisteredLogger)
            {
                if (aLogger.GetMinimumLogLevel() <= theLevel)
                {
                    aLogger.Log(aLog);
                }
            }
        }
    }
コード例 #5
0
ファイル: KGFDebugFile.cs プロジェクト: manboygames/capsa
 /// <summary>
 /// look into KGFIDebug documentation for further information
 /// </summary>
 public void SetMinimumLogLevel(KGFeDebugLevel theLevel)
 {
     itsDataDebugFile.itsMinimumLogLevel = theLevel;
 }
コード例 #6
0
ファイル: KGFDebugFile.cs プロジェクト: manboygames/capsa
 /// <summary>
 /// look into KGFIDebug documentation for further information
 /// </summary>
 public void Log(KGFeDebugLevel theLevel, string theCategory, string theMessage, string theStackTrace)
 {
     Log(theLevel, theCategory, theMessage, theStackTrace, null);
 }
コード例 #7
0
ファイル: KGFDebugFile.cs プロジェクト: manboygames/capsa
 /// <summary>
 /// look into KGFIDebug documentation for further information
 /// </summary>
 public void Log(KGFeDebugLevel theLevel, string theCategory, string theMessage)
 {
     Log(theLevel, theCategory, theMessage, string.Empty, null);
 }
コード例 #8
0
 /// <summary>
 /// sends the log command to all registered loggers
 /// </summary>
 /// <param name="theLevel">level of the log message</param>
 /// <param name="theCategory">category of the log message</param>
 /// <param name="theMessage">message of the log entry</param>
 private static void Log(KGFeDebugLevel theLevel, string theCategory, string theMessage)
 {
     Log(theLevel, theCategory, theMessage, null);
 }