本文整理汇总了C#中TraceEventType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TraceEventType.ToString方法的具体用法?C# TraceEventType.ToString怎么用?C# TraceEventType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraceEventType
的用法示例。
在下文中一共展示了TraceEventType.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TraceEvent
// ReSharper restore MethodOverloadWithOptionalParameter
// ReSharper disable MethodOverloadWithOptionalParameter
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
{
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (args == null)
// ReSharper restore ConditionIsAlwaysTrueOrFalse
// ReSharper disable HeuristicUnreachableCode
{
_traceLog.Clients.All.traceEvent(source, eventType.ToString(), id, format, args);
}
// ReSharper restore HeuristicUnreachableCode
else
{
_traceLog.Clients.All.traceEvent(source, eventType.ToString(), id, string.Format(CultureInfo.InvariantCulture, format, args));
}
}
示例2: 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;
}
}
}
}
示例3: TraceEvent
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
{
var levelChar = eventType.ToString().Substring(0, 1).ToUpper();
var dateFormat = DateTime.Now.ToString("0:MM/dd/yy H:mm:ss");
string fmt = string.Format("{0} {1} {2} ({3})", DateTime.Now.ToString(), levelChar, message, source);
this.WriteLine(fmt);
}
示例4: TraceData
public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
{
if ((Filter != null) && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data, null))
return;
var message = data.ToString();
WriteLine(message, eventType.ToString());
}
示例5: TraceEvent
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
{
if (eventType == TraceEventType.Information) {
WriteLine(String.Format("{0:HH:mm:ss.ffff} - {1}", eventCache.DateTime.ToLocalTime(), message));
} else {
WriteLine(String.Format("{0:HH:mm:ss.ffff} - {1}: {2}", eventCache.DateTime.ToLocalTime(), eventType.ToString().ToUpper(), message));
}
}
示例6: AppendHeader
private static void AppendHeader(this StringBuilder builder, string source, TraceEventType eventType, int id, string delimiter = DefaultDelimiter)
{
builder.Append(EscapedString(source));
builder.Append(delimiter);
builder.Append(eventType.ToString());
builder.Append(delimiter);
builder.Append(id.ToString(CultureInfo.InvariantCulture));
builder.Append(delimiter);
}
示例7: MessageWithTraceEventType
protected string MessageWithTraceEventType(TraceEventType traceEventType, string message)
{
string traceEventTypeString;
if (!TraceEventTypeStrings.TryGetValue(traceEventType, out traceEventTypeString))
{
traceEventTypeString = traceEventType.ToString();
}
return string.Format(CultureInfo.InvariantCulture, MessageWithTraceEventTypeFormat, traceEventTypeString, message);
}
示例8: TestTraceListenerThrowsOnErrorOrWarning
public void TestTraceListenerThrowsOnErrorOrWarning(TraceEventType traceEventType)
{
// Given
Engine engine = new Engine();
engine.Trace.AddListener(new TestTraceListener());
engine.Pipelines.Add(new Trace(traceEventType.ToString()).EventType(traceEventType));
// When/Then
Assert.Throws<Exception>(() => engine.Execute());
}
示例9: TestTraceListenerThrows
public void TestTraceListenerThrows(TraceEventType traceEventType)
{
// Given
Engine engine = new Engine();
engine.Pipelines.Add(new Trace(traceEventType.ToString()).EventType(traceEventType));
// When
TestDelegate test = () => engine.Execute();
// Then
Assert.Throws<Exception>(test);
}
示例10: Log
public void Log(TraceEventType type, Exception ex, IDictionary<string, object> additionalInfo, string messageFormat, params object[] args)
{
string messageText = args == null || args.Length == 0 ? messageFormat : String.Format(messageFormat, args);
string spiedMessage = String.Format("[{0}] {1}", type.ToString().ToUpperInvariant(), messageText);
for (; ex != null; ex = ex.InnerException)
spiedMessage += String.Format("\r\nEXCEPTION:\r\n{0}", ex);
if (additionalInfo != null && additionalInfo.Count != 0)
spiedMessage += String.Format("\r\nADDITIONAL INFO: {0}", String.Join(", ", additionalInfo.Select(kvp => String.Format("{0} = {1}", kvp.Key, kvp.Value))));
Messages.Add(spiedMessage);
}
示例11: TraceEvent
public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
{
if (this.Filter != null && !this.Filter.ShouldTrace(eventCache, source, eventType, id, message, null, null, null))
return;
StackTrace stackTrace = new StackTrace(true);
StackFrame[] stackFrames = stackTrace.GetFrames();
this.Writer.WriteLine("<entry date='" + Gateway.Now.ToShortDateString() + "' time='" + Gateway.Now.ToShortTimeString() + "' type='" +
eventType.ToString() + "' chainId='" + id + "'>" +
"<sender class='" + stackFrames[3].GetMethod().ReflectedType.Name + "." + stackFrames[3].GetMethod().Name + "' line='" + stackFrames[3].GetFileLineNumber() + "' />" +
"<message>" + message + "</message></entry>");
}
示例12: Write
public void Write( TraceEventType eventType, string message )
{
StreamWriter writer = File.AppendText( filename );
try
{
writer.WriteLine( "[{0:yyyy-MM-dd HH:mm:ss.fff}] {1}: {2}",
DateTime.Now, eventType.ToString(), message );
}
finally
{
writer.Close();
}
}
示例13: SendCampfireMessage
private void SendCampfireMessage(TraceEventCache eventCache, string source, TraceEventType eventType, int id, params object[] data)
{
// iterate through the data and create a single message
StringBuilder sb = new StringBuilder();
foreach (object item in data.Where(item => item != null))
sb.Append(item);
// Source LogLevel (id): message
string message = string.Format("{0} {1} ({2}): {3}", source, eventType.ToString(), id, sb.ToString());
_client.Post(message);
}
示例14: WriteEvent
private static void WriteEvent(TraceEventType eventType, CompositionTraceId traceId, string format, params object[] arguments)
{
const string LEVEL = "Level = ";
const string ID = " ,Id = ";
const string NEW_LINE = "\r\n";
StringBuilder sb = new StringBuilder (60);
sb.Append (LEVEL);
sb.Append (eventType);
sb.Append (ID);
sb.Append (traceId);
sb.Append (NEW_LINE);
sb.AppendFormat (format, arguments);
var mssage = eventType.ToString() + string.Format(format, arguments);
}
示例15: CreateLogMessage
internal static string CreateLogMessage(TraceEventType eventType, CompositionTraceId traceId, string format, params object[] arguments)
{
StringBuilder messageBuilder = new StringBuilder();
// Format taken from TraceListener.TraceEvent in full framework
messageBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0} {1}: {2} : ",
s_sourceName, eventType.ToString(), (int)traceId);
if (arguments == null)
{
messageBuilder.Append(format);
}
else
{
messageBuilder.AppendFormat(CultureInfo.InvariantCulture, format, arguments);
}
messageBuilder.AppendLine();
return messageBuilder.ToString();
}