public override void Log(Logger.MessageType severity_, string message_) { if (severity_ < Logger.MessageType.Debug) { return; } FileStream fileStream = (FileStream)null; StreamWriter streamWriter = (StreamWriter)null; string message_1 = DateTime.Now.ToString() + ": " + message_; lock (FileLog.b) { while (fileStream == null) { try { fileStream = new FileStream(this.d + this.a, FileMode.OpenOrCreate, FileAccess.Write); } catch (IOException exception_0) { fileStream = (FileStream)null; Thread.Sleep(0); } } try { streamWriter = new StreamWriter((Stream)fileStream); streamWriter.BaseStream.Seek(0L, SeekOrigin.End); streamWriter.WriteLine(message_1); streamWriter.Flush(); } finally { if (streamWriter != null) { streamWriter.Close(); } } } if (this.c == null) { return; } this.c(message_1); }
/// <summary> /// Set the log level of the Logger. All log records with a MessageType /// smaller or equal the log level will be logged. Logging to the Windows /// Event Log is not affected by the log level. /// </summary> /// <param name="level">One of the possible logging levels: /// <code>FAIL | ERROR | WARN | INFO | DEBUG</code></param> public static void SetLogLevel(String level) { if (level.ToUpper().Equals("INFO")) { globalLogLevel = MessageType.INFO; } else if (level.ToUpper().Equals("WARN")) { globalLogLevel = MessageType.WARN; } else if (level.ToUpper().Equals("ERROR")) { globalLogLevel = MessageType.ERROR; } else if (level.ToUpper().Equals("FAIL")) { globalLogLevel = MessageType.FAIL; } else { globalLogLevel = MessageType.DEBUG; } }
bool canShowMessage(Logger.MessageType type_) { return((showLogs && (type_ == Logger.MessageType.Log)) || (showWarnings && (type_ == Logger.MessageType.Warning)) || (showErrors && (type_ == Logger.MessageType.Error))); }
public abstract void Log(Logger.MessageType Severity, string Message);
public abstract void Log(Logger.MessageType Severity, Exception Message);
/// <summary> /// Makes a thread safe log message /// </summary> /// <param name="message"></param> private static void Log(string message, Logger.MessageType type) { Logger.Singleton.Log(message, type); }
public override void Log(Logger.MessageType severity_, Exception message_) { this.Log(severity_, message_.Message); }
private Logger() { globalLogLevel = MessageType.DEBUG; }
public LoggerOutputEventArgs(Logger.MessageType mtype, string msg) { MessageType = mtype; MessageText = msg; }