示例#1
0
        protected override void OnTraceReceived(TraceMessage message)
        {
            try
            {
                object syncRoot = _lockTable[_filename];

                lock (syncRoot)
                {
                    string directory = Path.GetDirectoryName(_filename);

                    if(!string.IsNullOrWhiteSpace(directory))
                        FileSystemHelper.EnsureDirectoryExists(directory);

                    using (StreamWriter writer = new StreamWriter(_filename, true))
                    {
                        writer.WriteLine(message);
                        writer.Flush();
                    }
                }
            }
            catch (Exception e)
            {
                Dispose(true);
                Tracer.Error(e);
            }
        }
        protected override void OnTraceReceived(TraceMessage message)
        {
            ConsoleColor color = ConsoleColor.Gray;

            switch (message.Type)
            {
                case TraceLevels.Info: color = ConsoleColor.White; break;
                case TraceLevels.Warning: color = ConsoleColor.Yellow; break;
                case TraceLevels.Error:
                case TraceLevels.Fatal: color = ConsoleColor.Red; break;
                default: break;
            }

            ConsoleHelper.PushColor(color);
            Console.WriteLine(message);
            ConsoleHelper.PopColor();
        }
示例#3
0
        public static void Trace(TraceLevels type, string message, params object[] args)
        {
            lock (_syncRoot)
            {
                if (TraceReceived != null)
                {
                    if (args.Length > 0)
                    {
                        message = string.Format(message, args);
                    }

                    TraceMessage traceMessage =
                        new TraceMessage(type, DateTime.UtcNow, message,
                                         string.IsNullOrEmpty(Thread.CurrentThread.Name) ? Thread.CurrentThread.ManagedThreadId.ToString() : Thread.CurrentThread.Name);

                    TraceReceived(new TraceMessageEventArgs(traceMessage));
                }
            }
        }
        protected override void OnTraceReceived(TraceMessage message)
        {
            ConsoleColor color = ConsoleColor.Gray;

            switch (message.Type)
            {
            case TraceLevels.Info: color = ConsoleColor.White; break;

            case TraceLevels.Warning: color = ConsoleColor.Yellow; break;

            case TraceLevels.Error:
            case TraceLevels.Fatal: color = ConsoleColor.Red; break;

            default: break;
            }

            ConsoleHelper.PushColor(color);
            Console.WriteLine(message);
            ConsoleHelper.PopColor();
        }
示例#5
0
        public TraceMessageEventArgs(TraceMessage traceMessage)
        {
            Guard.AssertIsNotNull(traceMessage, "traceMessage");

            TraceMessage = traceMessage;
        }
示例#6
0
 protected override void OnTraceReceived(TraceMessage message)
 {
     _console.WriteLine("{0}: {1}", message.Type, message.Message);
 }
示例#7
0
        public TraceMessageEventArgs(TraceMessage traceMessage)
        {
            Guard.AssertIsNotNull(traceMessage, "traceMessage");

            TraceMessage = traceMessage;
        }
示例#8
0
        public static void Trace(TraceLevels type, string message, params object[] args)
        {
            lock (_syncRoot)
            {
                if (TraceReceived != null)
                {
                    if (args.Length > 0)
                    {
                        message = string.Format(message, args);
                    }

                    TraceMessage traceMessage =
                        new TraceMessage(
                            type,
                            DateTime.UtcNow,
                            message,
                            string.IsNullOrEmpty(Thread.CurrentThread.Name)
                                ? Thread.CurrentThread.ManagedThreadId.ToString()
                                : Thread.CurrentThread.Name);

                    TraceReceived(new TraceMessageEventArgs(traceMessage));
                }
            }
        }
示例#9
0
 protected override void OnTraceReceived(TraceMessage message)
 {
     Debug.WriteLine(message);
 }
示例#10
0
 protected override void OnTraceReceived(TraceMessage message)
 {
     Debug.WriteLine(message);
 }