public TextWriterLogOutput(TextWriter target, TextLogOutputConfig config) { _target = target; _config = config ?? new TextLogOutputConfig(); if (_config.LogRotate) { _logRotator = new LogRotator(config); } }
public LogRotator(TextLogOutputConfig config) { _config = config; _observedFiles = new Stack <FileInfo>(); CreateLogScheduler(); }
/// <summary> /// Initializes a global logfile using the specified target directory and file name /// using default settings. If not specified otherwise, a Logs directory is used and /// the log file's name is derived from the current <see cref="DateTime"/>. /// </summary> public static TextWriterLogOutput InitGlobalLogFile(string directory = null, string fileName = null, TextLogOutputConfig config = null) { // In case someone calls this multiple times, shut down the old one ShutdownTextLog(); try { // Open a writable stream to the desired, default or fallback log file location string loggingPath; if (!TryCreateLogStream(directory, fileName, out _textFileLogWriter, out loggingPath)) { Logs.Default.WriteWarning("Text Logfile unavailable, because no logging location was accessible."); return(null); } config.LoggingPath = loggingPath; // Create, configure and register a log output using the log stream _textFileLogOutput = new TextWriterLogOutput(_textFileLogWriter, config); Logs.AddGlobalOutput(_textFileLogOutput); return(_textFileLogOutput); } catch (Exception e) { Logs.Default.WriteWarning("Failed to create text logfile: {0}", LogFormat.Exception(e)); return(null); } }