本文整理汇总了C#中LogSeverity类的典型用法代码示例。如果您正苦于以下问题:C# LogSeverity类的具体用法?C# LogSeverity怎么用?C# LogSeverity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogSeverity类属于命名空间,在下文中一共展示了LogSeverity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoryLogEntry
public StoryLogEntry(LogSeverity severity, string text, TimeSpan elapsed)
{
this.severity = severity;
this.text = text;
this.elapsed = elapsed;
this.dateTime = DateTime.UtcNow;
}
示例2: LogImpl
protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
{
StringBuilder fullMessage = new StringBuilder();
fullMessage.Append(GetCaption(severity));
fullMessage.Append(": ");
fullMessage.Append(message);
if (exceptionData != null)
fullMessage.Append('\n').Append(exceptionData);
switch (severity)
{
case LogSeverity.Debug:
facadeLogger.LogMessage(fullMessage.ToString());
break;
case LogSeverity.Info:
case LogSeverity.Important:
case LogSeverity.Warning:
facadeLogger.LogMessage(fullMessage.ToString());
break;
case LogSeverity.Error:
facadeLogger.LogError(fullMessage.ToString());
break;
}
}
示例3: LogImpl
protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
{
if (severity < MinLogSeverity || LogMessage == null)
return;
Color color = Color.Black;
switch (severity)
{
case LogSeverity.Error:
color = Color.Red;
break;
case LogSeverity.Warning:
color = Color.Gold;
break;
case LogSeverity.Important:
color = Color.Black;
break;
case LogSeverity.Info:
color = Color.Gray;
break;
case LogSeverity.Debug:
color = Color.DarkGray;
break;
}
LogMessage(this, new RuntimeLogEventArgs(message, color));
if (exceptionData != null)
LogMessage(this, new RuntimeLogEventArgs(exceptionData.ToString(), color));
}
示例4: Log
public void Log(string message, LogSeverity severity, Exception exception)
{
LastMessageSeverity = severity;
LastMessage = message;
LastException = exception;
MessagesReceived++;
}
示例5: LogImpl
protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
{
if (exceptionData != null)
message += "\n" + exceptionData;
switch (severity)
{
case LogSeverity.Error:
task.Log(Level.Error, message);
break;
case LogSeverity.Warning:
task.Log(Level.Warning, message);
break;
case LogSeverity.Important:
task.Log(Level.Info, message);
break;
case LogSeverity.Info:
task.Log(Level.Verbose, message);
break;
case LogSeverity.Debug:
task.Log(Level.Debug, message);
break;
}
}
示例6: SpellbookLoggerEventArgs
public SpellbookLoggerEventArgs(string message, object source, Exception exception, LogSeverity severity)
{
Message = message;
Source = source;
Exception = exception;
Severity = severity;
}
示例7: Log
/// <summary>
/// Logs the specified severity.
/// </summary>
/// <param name="severity">The severity.</param>
/// <param name="message">The message.</param>
public void Log(LogSeverity severity, string message)
{
RequiresNotNull(message);
var con = factory.OpenConnection();
con.ContinueWith(pt =>
{
var connection = pt.Result;
try
{
var cmd = connection.CreateCommand();
cmd.CommandText = "INSERT INTO Log (Id, Timestamp, Severity, Message) VALUES (NEWID(), @time, @sev, @msg)";
var timestampParameter = cmd.CreateParameter();
timestampParameter.ParameterName = "@time";
timestampParameter.Value = DateTime.Now;
cmd.Parameters.Add(timestampParameter);
var severityParameter = cmd.CreateParameter();
severityParameter.ParameterName = "@sev";
severityParameter.Value = severity.ToString();
cmd.Parameters.Add(severityParameter);
var messageParameter = cmd.CreateParameter();
messageParameter.ParameterName = "@msg";
messageParameter.Value = message;
cmd.Parameters.Add(messageParameter);
cmd.ExecuteNonQuery();
}
finally
{
connection.Dispose();
}
});
}
示例8: Log
/// <summary>
/// Log a message.
/// </summary>
/// <param name="severity">Severity.</param>
/// <param name="message">Message.</param>
/// <param name="args">Format arguments.</param>
public static void Log(LogSeverity severity, string message, params string[] args)
{
if (OnLog != null)
{
OnLog(severity, string.Format(message, args));
}
}
示例9: Log
public void Log(LogSeverity severity, string message, params object[] args)
{
if (!Environment.UserInteractive) return;
if ((int)severity < (int)this.minimalSeverity) return;
var color = Console.ForegroundColor;
switch (severity)
{
case LogSeverity.Debug:
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("{0}\t{1}\t{2}", severity, DateTime.Now, string.Format(message, args));
Console.ForegroundColor = color;
break;
case LogSeverity.Info:
case LogSeverity.Warn:
Console.WriteLine("{0}\t{1}\t{2}", severity, DateTime.Now, string.Format(message, args));
break;
case LogSeverity.Error:
case LogSeverity.Critical:
default:
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine("{0}\t{1}\t{2}", severity, DateTime.Now, string.Format(message, args));
Console.ForegroundColor = color;
break;
}
}
示例10: LogMessageEventArgs
public LogMessageEventArgs(LogSeverity severity, string source, string msg, Exception exception)
{
Severity = severity;
Source = source;
Message = msg;
Exception = exception;
}
示例11: LogItem
/// <summary>
/// Initializes a new instance of the <see cref="LogItem"/> struct.
/// </summary>
/// <param name="timestamp">The timestamp.</param>
/// <param name="severity">The severity.</param>
/// <param name="message">The message.</param>
public LogItem(DateTimeOffset? timestamp, LogSeverity severity, string message)
{
RequiresNotNull(message);
this.timestamp = timestamp;
this.severity = severity;
this.message = message;
}
示例12: LogEventArgs
/// <summary>
/// Constructor of LogEventArgs.
/// </summary>
/// <param name="severity">Log severity.</param>
/// <param name="message">Log message</param>
/// <param name="exception">Inner exception.</param>
/// <param name="date">Log date.</param>
public LogEventArgs(LogSeverity severity, string message, Exception exception, DateTime date)
{
Severity = severity;
Message = message;
Exception = exception;
Date = date;
}
示例13: Log
/// <inheritdoc />
public void Log(LogSeverity severity, string message, ExceptionData exceptionData)
{
if (message == null)
throw new ArgumentNullException("message");
LogImpl(severity, message, exceptionData);
}
示例14: LogImpl
/// <inheritdoc />
protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
{
switch (severity)
{
case LogSeverity.Error:
testListener.WriteLine(message, FacadeCategory.Error);
break;
case LogSeverity.Warning:
testListener.WriteLine(message, FacadeCategory.Warning);
break;
case LogSeverity.Important:
case LogSeverity.Info:
testListener.WriteLine(message, FacadeCategory.Info);
break;
case LogSeverity.Debug:
testListener.WriteLine(message, FacadeCategory.Debug);
break;
}
if (exceptionData != null)
testListener.WriteLine(exceptionData.ToString(), FacadeCategory.Error);
}
示例15: Log
public void Log(string message, LogSeverity logSeverity)
{
Console.ForegroundColor = DetermineColor(logSeverity);
Console.Write(message);
Console.WriteLine();
Console.ResetColor();
}