本文整理汇总了C#中TraceLevel类的典型用法代码示例。如果您正苦于以下问题:C# TraceLevel类的具体用法?C# TraceLevel怎么用?C# TraceLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TraceLevel类属于命名空间,在下文中一共展示了TraceLevel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Trace
public static void Trace(TraceLevel level, string message)
{
if (Utils.TraceListener != null && Utils.TraceListener.ShouldTrace(level))
{
Utils.TraceListener.Trace(level, message);
}
}
开发者ID:modulexcite,项目名称:IL2JS,代码行数:7,代码来源:Utils.cs
示例2: WriteLine
public static void WriteLine(TraceLevel level, string format, object arg1)
{
if (TraceListener != null && (level & TraceLevel) > 0)
{
TraceListener(format, arg1);
}
}
开发者ID:jimy811111,项目名称:Unity3d_MQTT,代码行数:7,代码来源:Trace.cs
示例3: Trace
/// <summary>
/// Writes the specified trace level, message and optional exception.
/// </summary>
/// <param name="level">The <see cref="TraceLevel"/> at which to write this trace.</param>
/// <param name="message">The trace message.</param>
/// <param name="ex">The trace exception. This parameter is optional.</param>
public void Trace(TraceLevel level, string message, Exception ex)
{
if (level == TraceLevel.Off)
{
return;
}
TraceEventCache eventCache = new TraceEventCache();
TraceEventType traceEventType = GetTraceEventType(level);
foreach (TraceListener listener in DiagnosticsTrace.Listeners)
{
if (!listener.IsThreadSafe)
{
lock (listener)
{
listener.TraceEvent(eventCache, "Newtonsoft.Json", traceEventType, 0, message);
}
}
else
{
listener.TraceEvent(eventCache, "Newtonsoft.Json", traceEventType, 0, message);
}
if (DiagnosticsTrace.AutoFlush)
{
listener.Flush();
}
}
}
开发者ID:cilliemalan,项目名称:Cargo,代码行数:36,代码来源:DiagnosticsTraceWriter.cs
示例4: InvokeTextWriter
protected override void InvokeTextWriter(TraceLevel level, string source, string message, Exception ex)
{
if (MapTraceLevel(source, level) <= _traceConfig.ConsoleLevel)
{
// For Errors/Warnings we change the Console color
// for visibility
var holdColor = Console.ForegroundColor;
bool changedColor = false;
switch (level)
{
case TraceLevel.Error:
Console.ForegroundColor = ConsoleColor.Red;
changedColor = true;
break;
case TraceLevel.Warning:
Console.ForegroundColor = ConsoleColor.Yellow;
changedColor = true;
break;
}
base.InvokeTextWriter(level, source, message, ex);
if (changedColor)
{
Console.ForegroundColor = holdColor;
}
}
}
开发者ID:GPetrites,项目名称:azure-webjobs-sdk,代码行数:28,代码来源:ConsoleTraceWriter.cs
示例5: WriteLog
private static void WriteLog(TraceLevel level, String messageText)
{
try
{
EventLogEntryType LogEntryType;
switch (level)
{
case TraceLevel.Error:
LogEntryType = EventLogEntryType.Error;
break;
default:
LogEntryType = EventLogEntryType.Error;
break;
}
String LogName = "Application";
if (!EventLog.SourceExists(LogName))
{
EventLog.CreateEventSource(LogName, "BIZ");
}
EventLog eventLog = new EventLog(LogName, ".", LogName);//��־���ԵĻ���
eventLog.WriteEntry(messageText, LogEntryType);
}
catch
{
}
}
开发者ID:W8023Y2014,项目名称:jsion,代码行数:27,代码来源:ApplicationLog.cs
示例6: TraceMessage
protected TraceMessage(string message, TraceLevel level)
{
Message = message;
Level = level;
Timestamp = DateTime.UtcNow;
ThreadId = Thread.CurrentThread.ManagedThreadId;
}
开发者ID:petabridge,项目名称:NBench,代码行数:7,代码来源:TraceEvent.cs
示例7: Trace
public void Trace(HttpRequestMessage request, string category, TraceLevel level,
Action<TraceRecord> traceAction)
{
var rec = new TraceRecord(request, category, level);
traceAction(rec);
WriteTrace(rec);
}
开发者ID:calebjenkins,项目名称:LinqToQuerystring,代码行数:7,代码来源:SimpleTracer.cs
示例8: Tracer
public Tracer(IFileSystem fileSystem, string path, TraceLevel level, IOperationLock traceLock)
{
_fileSystem = fileSystem;
_path = path;
_level = level;
_traceLock = traceLock;
}
开发者ID:richardprice,项目名称:kudu,代码行数:7,代码来源:Tracer.cs
示例9: WriteLine
/// <summary>
/// Writes the specified line to the trace log, processing the entry to
/// determine the trace level.
/// </summary>
/// <param name="message">The message to be written.</param>
public override void WriteLine( string message )
{
if( string.IsNullOrEmpty( message ) )
return;
if( this.fs == null )
return;
if( message.EndsWith( "Information: 0 : " ) )
{
this.type = TraceLevel.Info;
return;
}
else if( message.EndsWith( "Warning: 0 : " ) )
{
this.type = TraceLevel.Warning;
return;
}
else if( message.EndsWith( "Error: 0 : " ) )
{
this.type = TraceLevel.Error;
return;
}
lock( this.fs.Logs )
{
LogItem log = new LogItem( this.type, message );
this.fs.Logs.Add( log );
}
}
开发者ID:plamikcho,项目名称:xbrlpoc,代码行数:35,代码来源:FilingSummaryTraceWrapper.cs
示例10: Trace
public void Trace(
HttpRequestMessage request,
string category,
TraceLevel level,
Action<TraceRecord> traceAction)
{
var trace = new TraceRecord(request, category, level);
traceAction(trace);
_traces.Enqueue(trace);
var context = GlobalHost.ConnectionManager.GetConnectionContext<TracePersistentConnection>();
context.Groups.Send(
TracePersistentConnection.Authenticated,
new
{
trace.RequestId,
trace.Request.RequestUri,
Status = trace.Status.ToString(),
Level = trace.Level.ToString(),
trace.Message,
trace.Category,
TimeTicks = trace.Timestamp.Ticks,
trace.Operator,
trace.Operation,
Exception = trace.Exception == null ? "" : trace.Exception.Message,
});
}
开发者ID:clegendre,项目名称:webapi.sample.activetrace,代码行数:28,代码来源:TraceWriter.cs
示例11: SystemTraceWriter
public SystemTraceWriter(IEventGenerator eventGenerator, ScriptSettingsManager settingsManager, TraceLevel level) : base(level)
{
_settingsManager = settingsManager;
_appName = _settingsManager.AzureWebsiteDefaultSubdomain;
_subscriptionId = Utility.GetSubscriptionId();
_eventGenerator = eventGenerator;
}
开发者ID:Azure,项目名称:azure-webjobs-sdk-script,代码行数:7,代码来源:SystemTraceWriter.cs
示例12: WriteLine
public static void WriteLine(string message, TraceLevel level, params object[] args)
{
if (_switch.Level < level)
return;
string dateTimeOfEvent = DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffff");
string callingMethod = string.Empty;
try
{
callingMethod = new StackFrame(1).GetMethod().Name;
}
catch
{
// swallow
}
Trace.WriteLine(string.Format("{0} - {1}: {2}",
dateTimeOfEvent,
callingMethod,
args.Length == 0 ? message : string.Format(message, args)
));
}
开发者ID:yyf919,项目名称:CacheCow,代码行数:25,代码来源:TraceWriter.cs
示例13: DoTrace
static void DoTrace(TraceMessage message, TraceLevel level)
{
if (!message.CorrelationId.HasValue)
{
if (Trace.CorrelationManager.ActivityId != Guid.Empty)
{
message.CorrelationId = Trace.CorrelationManager.ActivityId;
}
}
using (var writer = new StringWriter())
{
_serializer.Serialize(writer, message);
// Can't use delegates here as all the Trace methods are [Conditional]
switch (level)
{
case TraceLevel.Info:
default:
Trace.TraceInformation(writer.ToString());
break;
case TraceLevel.Warning:
Trace.TraceWarning(writer.ToString());
break;
case TraceLevel.Error:
Trace.TraceError(writer.ToString());
break;
}
}
}
开发者ID:farukc,项目名称:Dash,代码行数:30,代码来源:DashTrace.cs
示例14: WriteLine
protected virtual void WriteLine(string context, string message, TraceLevel kind)
{
if (kind == TraceLevel.Off)
return;
if (kind != TraceLevel.Verbose)
{
try {
switch (kind)
{
case TraceLevel.Error:
Console.ForegroundColor = ConsoleColor.Red;
break;
case TraceLevel.Warning:
Console.ForegroundColor = ConsoleColor.Yellow;
break;
case TraceLevel.Info:
Console.ForegroundColor = ConsoleColor.Gray;
break;
}
Console.WriteLine("[{0}] {1} {2}", context, kind, message);
} finally {
Console.ForegroundColor = ConsoleColor.Gray;
}
}
this.LogFileWriter.WriteLine("[{0:MM/dd/yy HH:mm:ss}] [{1}] {2}: {3}", DateTime.Now, context, kind, message);
}
开发者ID:hastinbe,项目名称:TerrariaAPI-Server,代码行数:29,代码来源:ServerLogWriter.cs
示例15: LogData
public LogData(DateTime dateTime, TraceLevel level, string message, string category)
{
Time = dateTime;
Level = level;
Message = message;
Category = category;
}
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:7,代码来源:LogData.cs
示例16: TraceEntry
public TraceEntry(TraceLevel level, string message, object values = null)
{
Level = level;
Message = message;
Values = new DataValueDictionary(values);
TraceTime = DateTime.UtcNow;
}
开发者ID:bobasoft,项目名称:framework,代码行数:7,代码来源:TraceEntry.cs
示例17: FileTraceWriter
public FileTraceWriter(string logFilePath, TraceLevel level) : base(level)
{
_logFilePath = logFilePath;
_instanceId = GetInstanceId();
_logDirectory = new DirectoryInfo(logFilePath);
if (!_logDirectory.Exists)
{
_logDirectory.Create();
}
else
{
// query for all existing log files for this instance
// sorted by date, and get the last log file written to (or null)
var files = GetLogFiles(_logDirectory);
_currentLogFileInfo = files.FirstOrDefault();
}
if (_currentLogFileInfo == null)
{
SetNewLogFile();
}
// start a timer to flush accumulated logs in batches
_flushTimer = new Timer
{
AutoReset = true,
Interval = LogFlushIntervalMs
};
_flushTimer.Elapsed += OnFlushLogs;
_flushTimer.Start();
}
开发者ID:Azure,项目名称:azure-webjobs-sdk-script,代码行数:32,代码来源:FileTraceWriter.cs
示例18: Validate
public static void Validate(TraceLevel value, string parameterValue)
{
if (!IsDefined(value))
{
throw Error.InvalidEnumArgument(parameterValue, (int)value, typeof(TraceLevel));
}
}
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:7,代码来源:TraceLevelHelper.cs
示例19: Log
public void Log(TraceLevel level, string message, Exception ex)
{
switch (level)
{
case TraceLevel.Fatal:
Logger.Fatal(message, ex);
break;
case TraceLevel.Error:
Logger.Error(message, ex);
break;
case TraceLevel.Warn:
Logger.Warn(message, ex);
break;
case TraceLevel.Info:
Logger.Info(message, ex);
break;
case TraceLevel.Debug:
Logger.Debug(message, ex);
break;
}
}
开发者ID:aspnet,项目名称:WebHooks,代码行数:25,代码来源:Log4NetLogger.cs
示例20: Trace
public void Trace(HttpRequestMessage request, string category, TraceLevel level, Action<TraceRecord> traceAction)
{
if (request != null)
{
var traceQueryString = request.GetQueryString("trace"); ;
bool shouldTrace;
if (traceQueryString != null && Boolean.TryParse(traceQueryString, out shouldTrace)&& shouldTrace)
{
object perRequestTrace;
if (!request.Properties.TryGetValue("perRequestTrace", out perRequestTrace))
{
perRequestTrace = new List<string>();
request.Properties["perRequestTrace"] = perRequestTrace;
}
var record = new TraceRecord(request, category, level);
traceAction(record);
(perRequestTrace as List<string>).Add(Log(record));
}
}
if (_innerWriter != null)
{
_innerWriter.Trace(request, category, level, traceAction);
}
}
开发者ID:huoxudong125,项目名称:HQF.Tutorial.WebAPI,代码行数:27,代码来源:PerRequestTraceWriter.cs
注:本文中的TraceLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论