本文整理汇总了C#中LogLevel.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# LogLevel.Equals方法的具体用法?C# LogLevel.Equals怎么用?C# LogLevel.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogLevel
的用法示例。
在下文中一共展示了LogLevel.Equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogLine
protected override void LogLine(LogLevel level, string line)
{
if (level.Equals(LogLevel.Trace))
{
System.Diagnostics.Trace.WriteLine(line, m_logName);
}
else
{
System.Diagnostics.Debug.WriteLine(line, m_logName);
}
}
示例2: WriteLog
public static void WriteLog(LogLevel logLevel, String log)
{
if (logLevel.Equals(LogLevel.DEBUG))
{
logger.Debug(log);
}
else if (logLevel.Equals(LogLevel.ERROR))
{
logger.Error(log);
}
else if (logLevel.Equals(LogLevel.FATAL))
{
logger.Fatal(log);
}
else if (logLevel.Equals(LogLevel.INFO))
{
logger.Info(log);
}
else if (logLevel.Equals(LogLevel.WARNING))
{
logger.Warn(log);
}
}
示例3: log
/// <summary>
/// Log an exception object with custom additional information (for instance variable values at the time of the exception), example use in a catch block
/// </summary>
/// <param name="level">The LogLevel to assign to this message</param>
/// <param name="e">The exception object to log</param>
/// <param name="comment">Any additional information</param>
public void log(LogLevel level, Exception e, String comment)
{
if ((int)loggerLevel <= (int)level)
{
WPCException ex = new WPCException(level, e, comment);
if (Debugger.IsAttached)
{
Debug.WriteLine(ex.getDebugOutput());
}
if (toFile || level.Equals(LogLevel.critical))
{
logToFile(ex);
}
}
}
示例4: Log
/**
* Logs the exception to the appropriate log level if the exception is annotated with
* <code>@RestrictedLevel</code>. Otherwise log normally.
* @param log the logger
* @param logLevel the desired log level
* @param message the error message
* @param t the exception
*/
private static void Log (ILog log, LogLevel logLevel, object message, Exception ex)
{
string theMessage = BuildExceptionMessage(Convert.ToString(message), ex);
if (logLevel.Equals(LogLevel.Fatal))
{
log.Fatal(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Error))
{
log.Error(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Warn))
{
log.Warn(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Info))
{
log.Info(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Debug))
{
log.Debug(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Trace))
{
//log.Trace(theMessage, ex != null ? ex : null);
log.Debug(theMessage, ex != null ? ex : null);
}
}
示例5: WriteLog
public static void WriteLog(LogLevel logLevel, string log)
{
if (!IsLoggerConfigured)
{
return;
}
if (logLevel.Equals(LogLevel.DEBUG))
{
_logger.LogWriteLine("DEBUG- " + log);
}
else if (logLevel.Equals(LogLevel.ERROR))
{
_logger.LogWriteLine("ERROR- " + log);
}
else if (logLevel.Equals(LogLevel.FATAL))
{
_logger.LogWriteLine("FATAL- " + log);
}
else if (logLevel.Equals(LogLevel.INFO))
{
_logger.LogWriteLine("INFO- " + log);
}
else if (logLevel.Equals(LogLevel.WARN))
{
_logger.LogWriteLine("WARN- " + log);
}
else if (logLevel.Equals(LogLevel.MESSAGE))
{
_logger.LogWriteLine(log);
}
}
示例6: Log
/// <summary>
/// Logs information and writes it to the console
/// </summary>
/// <param name="message">The message to log</param>
/// <param name="level">LogLevel value, gets compared to the configured logLevel variable</param>
public void Log(object message, LogLevel level)
{
//set thread context properties
SetContext();
foreach (var log in logs) {
switch (level) {
case LogLevel.Trace:
//log4net has no Trace so Trace and Debug are the same
log.Debug(message);
break;
case LogLevel.Debug:
log.Debug(message);
break;
case LogLevel.Info:
log.Info(message);
break;
case LogLevel.Warn:
log.Warn(message);
break;
case LogLevel.Error:
log.Error(message);
break;
case LogLevel.Critical:
log.Fatal(message);
break;
}
}
//errors are special - they are exceptions that don't stop the program but we want to write them to a database
//table
if (level.Equals(LogLevel.Error) && errorLogDB != null && dataUtils != null) {
string headers = "Agent: " + Config.AgentType;
if (Config.Master != null) {
headers += " Master: " + Config.Master;
headers += " DB: " + Config.MasterDB;
} else if (Config.Slave != null) {
headers += " Slave: " + Config.Slave;
headers += " DB: " + Config.SlaveDB;
} else {
headers += " Relay: " + Config.RelayServer;
headers += " DB: " + Config.RelayDB;
}
dataUtils.LogError(message.ToString(), headers);
}
}
示例7: Print
public void Print(LogLevel level, string message)
{
if (level >= logLevel)
{
DateTime stamp = DateTime.Now;
StreamWriter logWriter;
if (!File.Exists(logFilePath))
logWriter = File.CreateText(logFilePath);
else
logWriter = File.AppendText(logFilePath);
string levelText = "";
if (level.Equals(LogLevel.Debug) || level.Equals(LogLevel.Info))
levelText = "[" + level.ToString() + "]\t\t";
if (level.Equals(LogLevel.Exception))
levelText = "[" + level.ToString() + "]\t";
string logOut = levelText + stamp.ToString("u") + "." + stamp.Millisecond.ToString("000") + " * " + message;
logWriter.WriteLine(logOut);
if (writeToConsole)
{
if (level.Equals(LogLevel.Exception))
{
var color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(logOut);
Console.ForegroundColor = color;
}
Console.WriteLine(logOut);
}
logWriter.Flush();
logWriter.Close();
}
}