当前位置: 首页>>代码示例>>C#>>正文


C# Diagnostics.TraceEventCache类代码示例

本文整理汇总了C#中System.Diagnostics.TraceEventCache的典型用法代码示例。如果您正苦于以下问题:C# TraceEventCache类的具体用法?C# TraceEventCache怎么用?C# TraceEventCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TraceEventCache类属于System.Diagnostics命名空间,在下文中一共展示了TraceEventCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TraceEvent

 public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
 {
     if (args == null || args.Length == 0)
         Append(eventType, format);
     else
         Append(eventType, String.Format(format, args));
 }
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:7,代码来源:MMLogTraceListener.cs

示例2: TraceData

		public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
		{
			tracedData = data;
			tracedSource = source;
			tracedEventType = eventType;
			entries.Add(data as LogEntry);
		}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:ErrorsMockTraceListener.cs

示例3: Write

		public void Write(LogEntry entry, Type filterListener)
		{
			Guard.ArgumentNotNull(entry, "entry");

			TraceEventCache manager = new TraceEventCache();

			foreach(TraceListener listener in this.Listeners)
			{
                bool lockTaken = false;
				try
				{                    
					if (!listener.IsThreadSafe)
					{
                        Monitor.Enter(sync, ref lockTaken);
					}
					if (filterListener == null ||
						filterListener == listener.GetType())
					{
						listener.TraceData(manager, string.Empty, entry.Severity, 0, entry);
						listener.Flush();
					}
				}
				finally
				{
                    if (!listener.IsThreadSafe && lockTaken)
					{
                        Monitor.Exit(sync);
					}
				}
			}
		}
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:31,代码来源:LogWriter.cs

示例4: TraceEvent

 public override sealed void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
 {
     if ((base.Filter == null) || base.Filter.ShouldTrace(eventCache, source, eventType, id, message, null, null, null))
     {
         WriteTrace(eventCache, source, eventType, id, message, null, null);
     }
 }
开发者ID:Myslik,项目名称:PugTrace,代码行数:7,代码来源:TraceListenerBase.cs

示例5: TraceEvent

        public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
        {
            if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, format, args, null, null))
            {
                return;
            }

            var client = new SmtpClient(Settings.Default.SmtpServer)
                {
                    Credentials = new NetworkCredential(Settings.Default.SmtpUsername, Settings.Default.SmtpPassword),
                    EnableSsl = true
                };
            var body = string.Format(format, args);
            var firstLine = new StringReader(body).ReadLine();
            if (firstLine.Length > 100)
            {
                firstLine = firstLine.Substring(0, 97).Trim() + "...";
            }
            var msg = new MailMessage
                {
                    From = new MailAddress(Settings.Default.NotificationFrom, "FitBot"),
                    To = {Settings.Default.NotificationTo},
                    Subject = $"{eventType} - {firstLine}",
                    Body = body
                };
            client.Send(msg);
        }
开发者ID:NathanBaulch,项目名称:FitBot,代码行数:27,代码来源:EmailTraceListener.cs

示例6: ShouldTrace

 /// <summary>
 /// Determines whether a filter is attached to this listener and, if so, asks whether it ShouldTrace applies to this data.
 /// </summary>
 protected virtual bool ShouldTrace(TraceEventCache eventCache, string source, TraceEventType eventType, int id,
                                    string formatOrMessage, object[] args, object data1, object[] data)
 {
     return
         !(Filter != null &&
           !Filter.ShouldTrace(eventCache, source, eventType, id, formatOrMessage, args, data1, data));
 }
开发者ID:Zoumaho,项目名称:Backload,代码行数:10,代码来源:CustomTraceListener.cs

示例7: TraceEvent

 public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id)
 {
     var te = new TraceEvent {Cache = eventCache, Source = source, Type = eventType, Id = id};
     Events.Add(te);
     if (OnEventAdd != null)
         OnEventAdd.Invoke(te);
 }
开发者ID:BastienDurel,项目名称:OCTGN,代码行数:7,代码来源:CacheTraceListener.cs

示例8: TraceData

 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 {
     LogMessage msg = (LogMessage)data;
     byte[] buf = FormatMessage(string.Concat(msg.MessageAsText, "\n"));
     Stream.Write(buf, 0, buf.Length);													// Write message buffer
     Stream.Flush();
 }
开发者ID:jbowwww,项目名称:JGL,代码行数:7,代码来源:MyConsoleTraceListener.cs

示例9: TraceEvent

		public override void TraceEvent (TraceEventCache eventCache, string source, TraceEventType severity, int id, string message)
		{
			if (HttpContext.Current == null || HttpContext.Current.Trace == null)
				return;

			HttpContext.Current.Trace.Write (source, message);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:WebPageTraceListener.cs

示例10: TraceEvent

        public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
        {
            lock (_sync)
            {
                if(Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, format, args, null, null)) return;
                ConsoleColor color;
                switch (eventType)
                {
                    case TraceEventType.Error:
                        color = ConsoleColor.Red;
                        break;
                    case TraceEventType.Warning:
                        color = ConsoleColor.Yellow;
                        break;
                    case TraceEventType.Information:
                        color = ConsoleColor.Green;
                        break;
                    case TraceEventType.Verbose:
                        color = ConsoleColor.DarkCyan;
                        break;
                    default:
                        color = ConsoleColor.Gray;
                        break;
                }

                var eventTypeString = Enum.GetName(typeof (TraceEventType), eventType);
                    var message = source + " - " + eventTypeString + " > " + (args.Length > 0 ? string.Format(format, args): format);

                WriteColor(message + Environment.NewLine, color);
            }
        }
开发者ID:theTwist84,项目名称:Open.NAT,代码行数:31,代码来源:ColorConsoleTraceListener.cs

示例11: TraceEvent

        public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
        {
            string message = string.Format(format, args);

            // write the localised date and time but include the time zone in brackets (good for combining logs from different timezones)
            TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
            string plusOrMinus = (utcOffset < TimeSpan.Zero) ? "-" : "+";
            string utcHourOffset = utcOffset.TotalHours == 0 ? string.Empty : string.Format(" ({0}{1:hh})", plusOrMinus, utcOffset);
            string dateWithOffset = string.Format(@"{0:yyyy/MM/dd HH:mm:ss.fff}{1}", DateTime.Now, utcHourOffset);

            // display the threadid
            string log = string.Format(@"{0} [{1}] {2}", dateWithOffset, Thread.CurrentThread.ManagedThreadId, message);

            switch (eventType)
            {
                case TraceEventType.Critical:
                case TraceEventType.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(log);
                    Console.ResetColor();
                    break;

                case TraceEventType.Warning:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(log);
                    Console.ResetColor();
                    break;

                default:
                    Console.WriteLine(log);
                    break;
            }
        }
开发者ID:modulexcite,项目名称:websocket-server,代码行数:33,代码来源:CustomConsoleTraceListener.cs

示例12: TraceEvent

        /// <summary>
        /// Traces the message. Supported event types are: Critical, Error, Information and Warning.
        /// </summary>
        public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
        {
            if (Logger != null)
            {
                switch (eventType)
                {
                    case TraceEventType.Critical:
                        {
                            Logger.Fatal(message);
                        }
                        break;

                    case TraceEventType.Error:
                        {
                            Logger.Error(message);
                        }
                        break;

                    case TraceEventType.Information:
                        {
                            Logger.Info(message);
                        }
                        break;

                    case TraceEventType.Warning:
                        {
                            Logger.Warn(message);
                        }
                        break;
                }
            }
        }
开发者ID:blake2002,项目名称:DatabaseBenchmark,代码行数:35,代码来源:TraceListener.cs

示例13: TraceData

 /// <summary>
 /// Forwards the trace request to the wrapped listener.
 /// </summary>
 /// <param name="eventCache">The context information.</param>
 /// <param name="source">The trace source.</param>
 /// <param name="severity">The severity.</param>
 /// <param name="id">The event id.</param>
 /// <param name="data">The objects to trace.</param>
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType severity, int id, params object[] data)
 {
     if ((this.Filter == null) || this.Filter.ShouldTrace(eventCache, source, severity, id, null, null, null, data))
     {
         this.innerListener.TraceData(eventCache, source, severity, id, data);
     }
 }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:15,代码来源:FormattedTraceListenerWrapperBase.cs

示例14: WriteEvent

		public void WriteEvent(string message, string source, TraceEventType type) {
			var ctx = BeforeWriteEvent();
			try {
				if (source == null) {
					source = s_processFileName;
				}
				var evtId = Interlocked.Increment(ref _evtId);
				var evtCache = new TraceEventCache();
				foreach (TraceListener l in listeners) {
					lock (l) {
						try {
							l.TraceEvent(evtCache, source, type, evtId, message);
							if (Trace.AutoFlush) {
								l.Flush();
							}
						} catch {
							//swallow error
							Debugger.Break();
						}
					}
				}
			} finally {
				AfterWriteEvent(ctx);
			}
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:25,代码来源:utils.LogUtils.cs

示例15: TraceEvent

 public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id)
 {
     if (_enabled)
     {
         WebSocketHost.Send($"{eventType}:{id} - {source}");
     }
 }
开发者ID:JayBeavers,项目名称:WebSocketTraceListener,代码行数:7,代码来源:WebTraceListener.cs


注:本文中的System.Diagnostics.TraceEventCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。