/// <summary> /// Sets up the logger object /// </summary> /// <param name="OutputTypes">A bitmask of OutputType (enum) specifying the output channels</param> /// <param name="LogFileName">The name of the file to use. If the file exists, it will be appended to</param> /// <param name="InitLoggingLevel">The level of the messages to log</param> /// <param name="TimeStampMask">A mask to apply to the DateTime object. For no timestamps, set to null</param> public Logger(int OutputTypes, string LogFileName, int InitLoggingLevel, string TimeStampMask) { StdOutLocker = new object(); FileLocker = new object(); ValidateLogLevel(InitLoggingLevel); CurrentLevel = (LoggingLevel)InitLoggingLevel; if ((OutputTypes & (int)OutputType.STDOUT) != 0) { TheWriterDelegate += this.ProcessSTDOut; } if ((OutputTypes & (int)OutputType.FILE) != 0) { if (String.IsNullOrEmpty(LogFileName)) { throw new Frost.Core.FrostException("Specified logging to file, but no filename was given"); } LogWriter = new StreamWriter(LogFileName, File.Exists(LogFileName)); if (String.IsNullOrEmpty(TimeStampMask)) { TimeStamp = "MMM-dd-yyyy HH:mm:ss.fffff"; } else { TimeStamp = TimeStampMask; } TheWriterDelegate += this.ProcessFileOut; } }
public void WriteMessage(string message) { if (InvokeRequired) { LogWriterDelegate d = new LogWriterDelegate(WriteMessage); Invoke(d, message); } else { MessagesTextBox.Text += message + Environment.NewLine; } }
public BaseForm() { InitializeComponent(); WriteLogMethod = new LogWriterDelegate(WriteLog); }
/// <summary> /// Sets up the logger object /// </summary> /// <param name="OutputTypes">A bitmask of OutputType (enum) specifying the output channels</param> /// <param name="LogFileName">The name of the file to use. If the file exists, it will be appended to</param> /// <param name="InitLoggingLevel">The level of the messages to log</param> /// <param name="TimeStampMask">A mask to apply to the DateTime object. For no timestamps, set to null</param> public Logger(int OutputTypes, string LogFileName, int InitLoggingLevel, string TimeStampMask) { StdOutLocker = new object(); FileLocker = new object(); ValidateLogLevel(InitLoggingLevel); CurrentLevel = (LoggingLevel)InitLoggingLevel; if ((OutputTypes & (int)OutputType.STDOUT) != 0) { TheWriterDelegate += this.ProcessSTDOut; } if ((OutputTypes & (int)OutputType.FILE) != 0) { if (String.IsNullOrEmpty(LogFileName)) { throw new Frost.Core.FrostException("Specified logging to file, but no filename was given"); } LogWriter = new StreamWriter(LogFileName, File.Exists(LogFileName)); if (String.IsNullOrEmpty(TimeStampMask)) { TimeStamp = "MMM-dd-yyyy HH:mm:ss.fffff"; } else { TimeStamp = TimeStampMask; } TheWriterDelegate += this.ProcessFileOut; } }
public BaseForm() { InitializeComponent(); WriteLogMethod = new LogWriterDelegate(WriteLog); }