Exemplo n.º 1
0
        /// <summary>
        /// Print Log Method
        /// </summary>
        /// <param name="message">Message to print</param>
        /// <param name="category">Category of message</param>
        /// <param name="timeStamp">Message timestamp</param>
        private void Print(string message, eLogCategory category, DateTime timeStamp)
        {
            LogMessage m = new LogMessage(message, category, timeStamp);

            lock (_inputMessageQtoken)
            {
                _inputMessageQ.Enqueue(m);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update Log function to be passed as delegate
        /// </summary>
        /// <param name="type">Log type</param>
        /// <param name="category">Log category</param>
        /// <param name="timestamp">Log timestamp</param>
        /// <param name="message">Log message</param>
        public void UpdateLog(eLogType type, eLogCategory category, DateTime timestamp, string message)
        {
            UILogMessage logmessage = new UILogMessage();

            logmessage.FontColor = DefineColor(category);
            logmessage.Message   = DefineMessage(type, category, timestamp, message);
            logmessage.Type      = type;
            Dispatcher.BeginInvoke(new ThreadStart(delegate
            {
                _logMessageList.Add(logmessage);
                if (AutoscrollCheckbox)
                {
                    _guiLog.ScrollIntoView(_logMessageList.Last());
                }
            }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Defines color for specific message category
        /// </summary>
        /// <param name="category">Message Category as string</param>
        /// <returns></returns>
        private Color DefineColor(eLogCategory category)
        {
            switch (category)
            {
            case eLogCategory.Error:
                return(Colors.Red);

            case eLogCategory.Info:
                return(Colors.DarkGreen);

            case eLogCategory.Warn:
                return(Colors.DarkOrange);

            default:
                return(Colors.Black);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Logging Messages used in logs
 /// </summary>
 /// <param name="message">Message description</param>
 /// <param name="category">Message Category</param>
 /// <param name="timeStamp">Message Time Stamp</param>
 public LogMessage(string message, eLogCategory category, DateTime timeStamp)
 {
     Description = message;
     _category   = category;
     TimeStamp   = timeStamp;
 }
Exemplo n.º 5
0
        private void Write(eLogCategory category, eLogLevel level, String message)
        {
            // Ensure the level is within desired levels
            CategoryConfig conf = configuration[category];
            if (level > conf._level)
            {
                return;
            }

            // Get the desired Output Stream for the Category
            StreamWriter outputStream;
            if (conf._useIndependantLog)
            {
                if (logWriters.ContainsKey(conf._logFile))
                {
                    outputStream = logWriters[conf._logFile];
                }
                else
                {
                    outputStream = new StreamWriter(conf._logFile, false, System.Text.Encoding.UTF8);
                    logWriters.Add(conf._logFile, outputStream);
                }
            }
            else
            {
                // Default File Writer
                outputStream = logWriters[generalLog];
            }

            // Add timestamp to the message
            if (AddTimeStamp)
            {
                DateTime current = DateTime.Now;
                message = string.Format("<{0:HH:mm:ss:fff}> [{1}] : {2} - {3}",
                                        current, level.ToString("G").PadRight(8), 
                                        category.ToString("G").PadRight(8), 
                                        message);
            }

            // Commit the message to the file
            if (null != outputStream)
            {
                outputStream.WriteLine(message);
                outputStream.Flush();
            }

#if !FINAL
            // Echo to the Console if a debug
            if (EchoToConsole)
            {
                if ((eLogLevel.Trace == level) ||
                    (eLogLevel.Info == level))
                {
                    UnityEngine.Debug.Log(message);
                }
                else if (eLogLevel.Warning == level)
                {
                    UnityEngine.Debug.LogWarning(message);
                }
                else // Both Error and Assert
                {
                    UnityEngine.Debug.LogError(message);
                }
            }
#endif
        }
Exemplo n.º 6
0
        public static void Assert(eLogCategory category, bool condition, String message)
        {
#if !FINAL
            if (condition)
            {
                return;
            }

            if (null != ARKLogger.Singleton)
            {
                ARKLogger.Singleton.Write(category, eLogLevel.Assert, message);

                if (ARKLogger.Singleton.BreakOnAssert)
                {
                    UnityEngine.Debug.Break();
                }
            }
            else
            {
                UnityEngine.Debug.Break();
            }
#endif
        }
Exemplo n.º 7
0
        public static void LogMessage(eLogCategory category, eLogLevel level, String message)
        {
#if !FINAL
            if (null != ARKLogger.Singleton)
            {
                ARKLogger.Singleton.Write(category, level, message);
            }
            else if (eLogLevel.System == level)
            {
                // Fallback if the debugging system hasn't been initialized yet.
                UnityEngine.Debug.Log(message);
            }
#endif
        }
Exemplo n.º 8
0
 /// <summary>
 /// Message to printable format
 /// </summary>
 /// <param name="message">Message to format</param>
 /// <param name="type">Type of log</param>
 /// <returns>Message as string</returns>
 private string DefineMessage(eLogType type, eLogCategory category, DateTime timestamp, string message)
 {
     return(String.Format("{0}\t{1}\t{3}", timestamp.ToString("HH:mm:ss:fff"), category, type, message));
 }