private void LoadOldLogs() { lock (_loggerLock) { var logDirectory = Path.GetDirectoryName(_logger.GetFile()); var files = logDirectory != null ? new DirectoryInfo(logDirectory).GetFiles() : new FileInfo[0]; foreach (var file in files) { if (file.Name.EndsWith(".log") && !file.Name.Equals(_logger.GetFileName())) { _oldLogs.Insert(0, new SkylineBatchLogger(file.FullName, _uiControl)); } } } }
private void TrimDisplayedLog() { var numLines = textBoxLog.Lines.Length; const int buffer = SkylineBatchLogger.MaxLogLines / 10; if (numLines > SkylineBatchLogger.MaxLogLines + buffer) { var unTruncated = textBoxLog.Text; var startIndex = textBoxLog.GetFirstCharIndexFromLine(numLines - SkylineBatchLogger.MaxLogLines); var message = (_skylineBatchLogger != null) ? string.Format(SkylineBatchLogger.LogTruncatedMessage, _skylineBatchLogger.GetFile()) : "... Log truncated ..."; message += Environment.NewLine; textBoxLog.Text = message + unTruncated.Substring(startIndex); textBoxLog.SelectionStart = 0; textBoxLog.SelectionLength = message.Length; textBoxLog.SelectionColor = Color.Red; } }