本文整理汇总了C#中LogLevel.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# LogLevel.CompareTo方法的具体用法?C# LogLevel.CompareTo怎么用?C# LogLevel.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogLevel
的用法示例。
在下文中一共展示了LogLevel.CompareTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkFilter
protected bool checkFilter(LogLevel level)
{
return (level.CompareTo(filter) < 0);
}
示例2: TryWriteLogEntry
/// <summary>
/// Writes a log entry in the GWL stream if the level is greater than
/// <code>MinimalLogLevel</code>
/// </summary>
/// <param name="level">Level of the log entry.</param>
/// <param name="message">Message of the log entry.</param>
/// <param name="engine">Engine instance used to geotag the log entry.</param>
/// <returns>True if the log entry's level was above or equal to the minimal required
/// level and the entry was successfully written on the stream, false otherwise.</returns>
public bool TryWriteLogEntry(LogLevel level, string message, Engine engine)
{
// Checks if the entry is allowed to be displayed at all.
if (level.CompareTo(MinimalLogLevel) < 0)
{
return false;
}
// Tries to write the message.
try
{
_writer.WriteLine(engine.CreateLogMessage(message));
return true;
}
catch (Exception)
{
return false;
}
}
示例3: Write
/// <summary>
/// Writes the specified level logs.
/// </summary>
/// <param name="level">The level.</param>
/// <param name="message">The message.</param>
private void Write(LogLevel level, string message)
{
if (level.CompareTo(_appSettingLogLevel) < 0) return;
if (_writer == null) return;
if (string.IsNullOrWhiteSpace(message)) return;
Write(new LogEntry(
message,
DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture),
Thread.CurrentThread.ManagedThreadId.ToString("000", CultureInfo.InvariantCulture),
level));
}