本文整理汇总了C#中ILogFormatter.Format方法的典型用法代码示例。如果您正苦于以下问题:C# ILogFormatter.Format方法的具体用法?C# ILogFormatter.Format怎么用?C# ILogFormatter.Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogFormatter
的用法示例。
在下文中一共展示了ILogFormatter.Format方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString
public string ToString(ILogFormatter formatter)
{
if (formatter == null) return ToString();
try
{
return formatter.Format(this);
}
catch
{
return ToString();
}
}
示例2: Append
/// <summary>
/// Escreve o resultado de um <see cref="LogEntry"/> no <see cref="System.Console"/>.
/// </summary>
/// <param name="logger">O logger</param>
/// <param name="formatter">O formatador</param>
/// <param name="entry">A entrada no log</param>
public void Append(ILogger logger, ILogFormatter formatter, LogEntry entry)
{
Console.WriteLine(formatter.Format(entry));
}
示例3: Log
public void Log(LogEntry entry, ILogFormatter formatter)
{
if (!_Enabled) return;
SplitLog();
try
{
string logLine = formatter.Format(entry) + "\r\n";
File.AppendAllText(_Location, logLine);
}
catch { return; }
}
示例4: Log
public void Log(string message, LogLevel logLevel, ILogFormatter logFormatter)
{
this.LastMessage = logFormatter.Format(message, logLevel, LogTime);
this.LastLogLevel = logLevel;
this.LastLogFormatter = logFormatter;
}
示例5: AssertSerializingLogFormatter
internal static void AssertSerializingLogFormatter(ILogFormatter logFormatter, Mock<ISerializer> mockSerializer)
{
Assert.That(logFormatter.Format(null), Is.EqualTo("Hello, world!"));
mockSerializer.Verify(m => m.SerializeToString(It.IsAny<object>(), It.IsAny<Type>()), Times.Once());
}
示例6: FormatEntry
/// <summary>
/// Formats the given <see cref="LogEntry"></see> through the given <see cref="ILogFormatter"></see>
/// </summary>
/// <param name="formatter">Instance of class implementing the <see cref="ILogFormatter"></see> interface</param>
/// <param name="logEntry">The <see cref="LogEntry"></see> to format</param>
/// <returns>The formatted <see cref="LogEntry"></see></returns>
protected virtual string FormatEntry(ILogFormatter formatter, LogEntry logEntry)
{
string formattedMessage = formatter.Format(logEntry);
if (logEntry.ErrorMessages != null)
{
formattedMessage = logEntry.ErrorMessages.ToString() + "Message: " +
Environment.NewLine + formattedMessage;
}
return formattedMessage;
}
示例7: Log
public void Log(string message, LogLevel logLevel, ILogFormatter logFormatter)
{
Debug.WriteLine(logFormatter.Format(message, logLevel, DateTime.Now));
}