• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Diagnostics.TraceEventCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TraceSimpleEvent

        protected override void TraceSimpleEvent(DateTime eventTime, Int32 threadId, TraceEventType eventType, String message, Int32 eventId, TraceEventCache eventCache, String source)
        {
            if (_table != null)
            {
                if (message.StartsWith("#Status ") || message.StartsWith("#Status:"))
                {
                    Status status = new Status(eventTime.ToUniversalTime());
                    status.Level = eventType.ToString();
                    status.ThreadId = threadId;

                    string messageText;
                    string dataText;
                    GetMessageParts(message, out messageText, out dataText);
                    status.Message = messageText;
                    status.Data = dataText;

                    try
                    {
                        TableOperation operation = TableOperation.Insert(status);
                        this._table.Execute(operation);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception while saving to Azure storage.");
                        Console.WriteLine(e.ToString());
                        throw;
                    }
                }
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:30,代码来源:AzureTableStorageStatusTraceListener.cs


示例17: TraceEvent

 public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id)
 {
     this.source = source;
     this.eventType = eventType;
     this.id = id;
     TraceEvent(eventCache, source, eventType, id, "No additional information.");
 }
开发者ID:yong-ja,项目名称:starodyssey,代码行数:7,代码来源:ConsoleTraceListener.cs


示例18: PrintThreadId

 void PrintThreadId(TraceEventCache info)
 {
     Console.Out.Write("[");
     Console.Out.Write(info.ThreadId);
     Console.Out.Write("]");
     Console.Out.Write(" ");
 }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:7,代码来源:ColorConsoleLogger.cs


示例19: TryGetValue

 /// <summary>
 /// Returns the value of Environment.MachineName
 /// </summary>
 /// <param name="value">The output parameter</param>
 /// <param name="cache">Unused</param>
 /// <param name="source">Unused</param>
 /// <param name="eventType">Unused</param>
 /// <param name="id">Unused</param>
 /// <param name="formatOrMessage">Unused</param>
 /// <param name="data">Unused</param>
 /// <returns>True</returns>
 public override bool TryGetValue(out object value, TraceEventCache cache, string source,
                                  TraceEventType eventType, int id, string formatOrMessage,
                                  object[] data)
 {
     value = Environment.MachineName;
     return true;
 }
开发者ID:Balansir,项目名称:Backload,代码行数:18,代码来源:MachineNamePropertyReader.cs


示例20: TraceEvent

 public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
 {
     ConsoleColor originalColor = Console.ForegroundColor;
     Console.ForegroundColor = GetEventColor(eventType, originalColor);
     base.WriteLine(string.Format(format, args));
     Console.ForegroundColor = originalColor;
 }
开发者ID:martinvobr,项目名称:Wyam,代码行数:7,代码来源:SimpleColorConsoleTraceListener.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Diagnostics.TraceListener类代码示例发布时间:2022-05-26
下一篇:
C# Diagnostics.TextWriterTraceListener类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap