Пример #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))
                    {
                        writer.WriteLine(message);
                        writer.Flush();
                    }
                }
            }
            catch (Exception e)
            {
                Dispose(true);
                Tracer.Error(e);
            }
        }
Пример #2
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));
                }
            }
        }
Пример #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));
                }
            }
        }
        public TraceMessageEventArgs(TraceMessage traceMessage)
        {
            Asserter.AssertIsNotNull(traceMessage, "traceMessage");

            TraceMessage = traceMessage;
        }
        public TraceMessageEventArgs(TraceMessage traceMessage)
        {
            Asserter.AssertIsNotNull(traceMessage, "traceMessage");

            TraceMessage = traceMessage;
        }