Пример #1
0
        /// <summary>
        /// Write debug message to log
        /// </summary>
        /// <param name="text">The debug text to log</param>
        public void Debug(string text)
        {
            var log = new LogEntry(text, DateTime.Now, LogType.Debug);
            _logs.Enqueue(log);
            OnLogEvent(log);

            _trace.WriteLine(DateTime.Now.ToString(DateFormat) + " Debug:: " + text);
        }
Пример #2
0
        /// <summary>
        /// Write error message to log
        /// </summary>
        /// <param name="text">The error text to log</param>
        public void Error(string text)
        {
            var log = new LogEntry(text, DateTime.Now, LogType.Error);
            _logs.Enqueue(log);
            OnLogEvent(log);

            Console.ForegroundColor = ConsoleColor.Red;
            _error.WriteLine(DateTime.Now.ToString(DateFormat) + " Error:: " + text);
            Console.ResetColor();
        }
Пример #3
0
        /// <summary>
        /// Raise a log event safely
        /// </summary>
        protected virtual void OnLogEvent(LogEntry log)
        {
            var handler = LogEvent;

            if (handler != null)
            {
                handler(log);
            }
        }