public IList<OrderedOutput> HandleMethodExit(MethodExit logEntry, int lineNo, ILogFilters filters, Func<DateTime, string> lineBuilder, bool displayEnabled) { if (!displayEnabled) { // method is not actually displayed, we are tracking the nesting level for other items displayed such as logs, exceptions, etc _currentNestedLevel--; return null; } if ((_lastMethodEntry == null) || (_lastMethodEntry.Count <= 0)) throw new InvalidOperationException(String.Format("No related Method Entry log has been set for '{0}' at line {1:0000} - there could be a problem with the yalf logs." , logEntry.MethodName, lineNo)); if (_lastMethodEntry.Peek().MethodName != logEntry.MethodName) throw new InvalidOperationException(String.Format("The method exit log '{1}' has a different name than the current method entry log '{0}' at line {2:0000} - there could be a problem with the yalf logs." , _lastMethodEntry.Peek().MethodName, logEntry.MethodName, lineNo)); var currentMethodEntry = _lastMethodEntry.Pop(); _currentNestedLevel--; int indexOfEntryToUpdate = FindLastIndexOf(currentMethodEntry); if (indexOfEntryToUpdate < 0) throw new InvalidOperationException(String.Format("Could not find the method [{0}] in the current ordered buffer. This probably means there is an error in the processing logic, or the yalf file is corrupt.", currentMethodEntry.MethodName)); var currentItem = _orderedBuffer[indexOfEntryToUpdate]; _orderedBuffer[indexOfEntryToUpdate] = new LogEntryTracker(currentItem.Level, currentItem.RelatedEntry, lineBuilder(currentMethodEntry.Time)); if (_lastMethodEntry.Count > 0) return null; _currentNestedLevel = 0; return this.PrepareOutputBuffer(); }
public string FormatLogEvent(int threadId, int level, int lineNo, LogEvent logEntry, ILogFilters filters, bool displayEnabled) { if (!displayEnabled) return null; return _delayedService.HandleLogEvent(this.BuildOutputLine("Log", logEntry.Message, "", logEntry.Time, 0, level, threadId)); }
public string FormatLogEvent(int threadId, int level, int lineNo, LogEvent logEntry, ILogFilters filters, bool displayEnabled) { if (!displayEnabled) return null; return string.Format("[Log] [{0}] {1}", logEntry.Level, logEntry.Message); }
public string FormatThread(ThreadData logEntry, ILogFilters filters) { var outputFormat = "[Thread {0} '{1}']"; if (String.IsNullOrEmpty(logEntry.ThreadName)) outputFormat = "[Thread {0}]"; return String.Format(outputFormat, logEntry.ThreadId, logEntry.ThreadName); }
public DefaultOutputHandler(ILogFilters filters, ILogFormatter formatter) { if (filters == null) throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation."); this.Filters = filters; this.Formatter = formatter; }
public string FormatMethodEntry(int threadId, int level, int lineNo, MethodEntry logEntry, ILogFilters filters, bool displayEnabled) { if ((filters.HideEnterMethodLogs) || (!displayEnabled)) return null; var args = ((logEntry.Arguments == null) || filters.HideMethodParameters) ? "" : string.Join(", ", logEntry.Arguments); var timeText = filters.HideTimeStampInMethod ? "" : string.Concat(this.FormatTime(logEntry.Time), " "); return string.Format("[Enter] {0}{1}({2})", timeText, logEntry.MethodName, args); }
public static void Save(string settingsFilePath, ILogFilters filters) { var serial = new XmlSerializer(typeof(LogFiltersBuilder)); var settings = new XmlWriterSettings() { Indent = true }; using (var writer = XmlWriter.Create(settingsFilePath, settings)) { serial.Serialize(writer, LogFiltersBuilder.Create(filters)); } }
public CsvFileOutputHandler(ILogFilters filters, ILogFormatter formatter, String filePath) { if (filters == null) throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation."); this.Filters = filters; this.Formatter = formatter; this.FilePath = filePath; }
/// <summary> /// Collates nested log calls and only returns an list of formatted log strings when a top level method exit log entry is envcountered /// </summary> /// <remarks> /// <para>This is required as, due to the nature of the single line formatter, nested logs are returned in the wrong order with the normal <see cref="FormatMethodExit"/> method.</para> /// <para>The indent must still be applied to the strings in the returned list in the <see cref="ILogOutputHandler"/>. The first item will be the top level method call.</para> /// </remarks> public IList<OrderedOutput> FormatMethodExitForSingleLineOutput(int threadId, int level, int lineNo, MethodExit logEntry, ILogFilters filters, bool displayEnabled) { Func<DateTime, String> lineBuilder = null; if (displayEnabled) lineBuilder = this.CreateMethodExitLineGenerator(logEntry, filters); return _delayedService.HandleMethodExit(logEntry, lineNo, filters, lineBuilder, displayEnabled); }
public DefaultOutputHandler(ILogFilters filters, ILogFormatter formatter) { if (filters == null) { throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation."); } this.Filters = filters; this.Formatter = formatter; }
public FilterableLogEntryList(IEnumerable<BaseEntry> entries, ILogFilters filters) { _logEntries = entries; _flags = new Dictionary<string, bool>(); this.Filters = filters; this.CalculateStartAndEndTimes(); this.SetupFilterList(); }
public FilterableLogEntryList(IEnumerable <BaseEntry> entries, ILogFilters filters) { _logEntries = entries; _flags = new Dictionary <string, bool>(); this.Filters = filters; this.CalculateStartAndEndTimes(); this.SetupFilterList(); }
public CsvFileOutputHandler(ILogFilters filters, ILogFormatter formatter, String filePath) { if (filters == null) { throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation."); } this.Filters = filters; this.Formatter = formatter; this.FilePath = filePath; }
public TextWriterOutputHandler(TextWriter writer, ILogFilters filters, ILogFormatter formatter) { if (writer == null) throw new ArgumentNullException("writer", "A valid stream writer is required for proper operation."); if (filters == null) throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation."); this.Filters = filters; this.Formatter = formatter; this.Writer = writer; }
public string FormatThread(ThreadData logEntry, ILogFilters filters) { var outputFormat = "[Thread {0} '{1}']"; if (String.IsNullOrEmpty(logEntry.ThreadName)) { outputFormat = "[Thread {0}]"; } return(String.Format(outputFormat, logEntry.ThreadId, logEntry.ThreadName)); }
public string FormatMethodExit(int threadId, int level, int lineNo, MethodExit logEntry, ILogFilters filters, bool displayEnabled) { if ((filters.HideExitMethodLogs) || (!displayEnabled)) return null; var returnValue = (logEntry.ReturnRecorded && !filters.HideMethodReturnValue) ? "(" + logEntry.ReturnValue + ")" : "()"; if (filters.HideMethodDuration) return string.Format("[Exit] {0}{1}", logEntry.MethodName, returnValue); return string.Format("[Exit] {0}{1} duration {2:0.####}ms", logEntry.MethodName, returnValue, logEntry.ElapsedMs); }
public LogFiltersBuilder(ILogFilters filters) { this.IncludedKeysExpressionList = filters.IncludedKeysExpressionList.ToList(); this.ExcludedKeysExpressionList = filters.ExcludedKeysExpressionList.ToList(); this.TimeStampFrom = filters.TimeStampFrom; this.TimeStampTo = filters.TimeStampTo; this.IgnoreCaseInFilter = filters.IgnoreCaseInFilter; this.HideEnterMethodLogs = filters.HideEnterMethodLogs; this.HideExitMethodLogs = filters.HideExitMethodLogs; this.HideTimeStampInMethod = filters.HideTimeStampInMethod; this.HideMethodParameters = filters.HideMethodParameters; this.HideMethodDuration = filters.HideMethodDuration; this.HideMethodReturnValue = filters.HideMethodReturnValue; this.SingleLineFormat = filters.SingleLineFormat; }
public TextWriterOutputHandler(TextWriter writer, ILogFilters filters, ILogFormatter formatter) { if (writer == null) { throw new ArgumentNullException("writer", "A valid stream writer is required for proper operation."); } if (filters == null) { throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation."); } this.Filters = filters; this.Formatter = formatter; this.Writer = writer; }
public string FormatLogEvent(int threadId, int level, int lineNo, LogEvent logEntry, ILogFilters filters, bool displayEnabled) { return _delayedService.HandleLogEvent(_default.FormatLogEvent(threadId, level, lineNo, logEntry, filters, displayEnabled)); }
public string FormatThread(ThreadData logEntry, ILogFilters filters) { return(null); }
private Func<DateTime, string> CreateLineBuilderGenerator(int threadId, int level, MethodExit logEntry, ILogFilters filters) { var returnValue = (logEntry.ReturnRecorded && !filters.HideMethodReturnValue) ? logEntry.ReturnValue : ""; return startTime => BuildOutputLine("Method", logEntry.MethodName, returnValue, startTime, logEntry.ElapsedMs, level, threadId); }
public IList <OrderedOutput> HandleMethodExit(MethodExit logEntry, int lineNo, ILogFilters filters, Func <DateTime, string> lineBuilder, bool displayEnabled) { if (!displayEnabled) { // method is not actually displayed, we are tracking the nesting level for other items displayed such as logs, exceptions, etc _currentNestedLevel--; return(null); } if ((_lastMethodEntry == null) || (_lastMethodEntry.Count <= 0)) { throw new InvalidOperationException(String.Format("No related Method Entry log has been set for '{0}' at line {1:0000} - there could be a problem with the yalf logs." , logEntry.MethodName, lineNo)); } if (_lastMethodEntry.Peek().MethodName != logEntry.MethodName) { throw new InvalidOperationException(String.Format("The method exit log '{1}' has a different name than the current method entry log '{0}' at line {2:0000} - there could be a problem with the yalf logs." , _lastMethodEntry.Peek().MethodName, logEntry.MethodName, lineNo)); } var currentMethodEntry = _lastMethodEntry.Pop(); _currentNestedLevel--; int indexOfEntryToUpdate = FindLastIndexOf(currentMethodEntry); if (indexOfEntryToUpdate < 0) { throw new InvalidOperationException(String.Format("Could not find the method [{0}] in the current ordered buffer. This probably means there is an error in the processing logic, or the yalf file is corrupt.", currentMethodEntry.MethodName)); } var currentItem = _orderedBuffer[indexOfEntryToUpdate]; _orderedBuffer[indexOfEntryToUpdate] = new LogEntryTracker(currentItem.Level, currentItem.RelatedEntry, lineBuilder(currentMethodEntry.Time)); if (_lastMethodEntry.Count > 0) { return(null); } _currentNestedLevel = 0; return(this.PrepareOutputBuffer()); }
public DefaultOutputHandler(ILogFilters filters) : this(filters, new DefaultFormatter()) { }
public string FormatMethodExit(int threadId, int level, int lineNo, MethodExit logEntry, ILogFilters filters, bool displayEnabled) { throw new NotImplementedException(String.Format("{0} does not need to immplement this method, use the ISingleLineOutputLogFormatter.FormatMethodExitForSingleLineOutput interface method so the calls are in the right order.", this.GetType().Name)); }
public ThreadCollectionOutputHandler(ILogFilters filters, ILogFormatter formatter) : base(filters, formatter) { _threadEntries = new Dictionary<int, List<String>>(20); }
public string FormatLogEvent(int threadId, int level, int lineNo, LogEvent logEntry, ILogFilters filters, bool displayEnabled) { if (!displayEnabled) { return(null); } return(string.Format("[Log] [{0}] {1}", logEntry.Level, logEntry.Message)); }
public string FormatException(int threadId, int level, int lineNo, ExceptionTrace logEntry, ILogFilters filters) { return(string.Format("[Exception] {0} {1}", this.FormatTime(logEntry.Time), logEntry.Message)); }
public string FormatMethodExit(int threadId, int level, int lineNo, MethodExit logEntry, ILogFilters filters, bool displayEnabled) { if ((filters.HideExitMethodLogs) || (!displayEnabled)) { return(null); } var returnValue = (logEntry.ReturnRecorded && !filters.HideMethodReturnValue) ? "(" + logEntry.ReturnValue + ")" : "()"; if (filters.HideMethodDuration) { return(string.Format("[Exit] {0}{1}", logEntry.MethodName, returnValue)); } return(string.Format("[Exit] {0}{1} duration {2:0.####}ms", logEntry.MethodName, returnValue, logEntry.ElapsedMs)); }
public string FormatMethodEntry(int threadId, int level, int lineNo, MethodEntry logEntry, ILogFilters filters, bool displayEnabled) { if ((filters.HideEnterMethodLogs) || (!displayEnabled)) { return(null); } var args = ((logEntry.Arguments == null) || filters.HideMethodParameters) ? "" : string.Join(", ", logEntry.Arguments); var timeText = filters.HideTimeStampInMethod ? "" : string.Concat(this.FormatTime(logEntry.Time), " "); return(string.Format("[Enter] {0}{1}({2})", timeText, logEntry.MethodName, args)); }
public ThreadCollectionOutputHandler(ILogFilters filters) : this(filters, new DefaultFormatter()) { }
public ThreadCollectionOutputHandler(ILogFilters filters, ILogFormatter formatter) : base(filters, formatter) { _threadEntries = new Dictionary <int, List <String> >(20); }
public static LogFiltersBuilder Create(ILogFilters copyFilters) { return(new LogFiltersBuilder(copyFilters)); }
public static LogFiltersBuilder Create(ILogFilters copyFilters) { return new LogFiltersBuilder(copyFilters); }
public string FormatThread(ThreadData logEntry, ILogFilters filters) { return(_default.FormatThread(logEntry, filters)); }
public TextWriterOutputHandler(TextWriter writer, ILogFilters filters) : this(writer, filters, new DefaultFormatter()) { }
public string FormatThread(ThreadData logEntry, ILogFilters filters) { return _default.FormatThread(logEntry, filters); }
public string FormatLogEvent(int threadId, int level, int lineNo, LogEvent logEntry, ILogFilters filters, bool displayEnabled) { if (!displayEnabled) { return(null); } return(_delayedService.HandleLogEvent(this.BuildOutputLine("Log", logEntry.Message, "", logEntry.Time, 0, level, threadId))); }
private Func <DateTime, string> CreateLineBuilderGenerator(int threadId, int level, MethodExit logEntry, ILogFilters filters) { var returnValue = (logEntry.ReturnRecorded && !filters.HideMethodReturnValue) ? logEntry.ReturnValue : ""; return(startTime => BuildOutputLine("Method", logEntry.MethodName, returnValue, startTime, logEntry.ElapsedMs, level, threadId)); }
public string FormatThread(ThreadData logEntry, ILogFilters filters) { return null; }
public string FormatException(int threadId, int level, int lineNo, ExceptionTrace logEntry, ILogFilters filters) { return(_delayedService.HandleException(_default.FormatException(threadId, level, lineNo, logEntry, filters))); }
public string FormatException(int threadId, int level, int lineNo, ExceptionTrace logEntry, ILogFilters filters) { var stackTrace = (logEntry.StackTrace == null) ? "" : logEntry.StackTrace.Replace(Environment.NewLine, " "); return _delayedService.HandleException(this.BuildOutputLine("Exception", logEntry.Message.Replace(Environment.NewLine, " "), stackTrace, logEntry.Time, 0, level, threadId)); }
public string FormatLogEvent(int threadId, int level, int lineNo, LogEvent logEntry, ILogFilters filters, bool displayEnabled) { return(_delayedService.HandleLogEvent(_default.FormatLogEvent(threadId, level, lineNo, logEntry, filters, displayEnabled))); }
public string FormatException(int threadId, int level, int lineNo, ExceptionTrace logEntry, ILogFilters filters) { return _delayedService.HandleException(_default.FormatException(threadId, level, lineNo, logEntry, filters)); }
public string FormatException(int threadId, int level, int lineNo, ExceptionTrace logEntry, ILogFilters filters) { var stackTrace = (logEntry.StackTrace == null) ? "" : logEntry.StackTrace.Replace(Environment.NewLine, " "); return(_delayedService.HandleException(this.BuildOutputLine("Exception", logEntry.Message.Replace(Environment.NewLine, " "), stackTrace, logEntry.Time, 0, level, threadId))); }
public string FormatMethodEntry(int threadId, int level, int lineNo, MethodEntry logEntry, ILogFilters filters, bool displayEnabled) { // entry details are merged with exit details return _delayedService.HandleMethodEntry(logEntry, displayEnabled); }
public string FormatMethodEntry(int threadId, int level, int lineNo, MethodEntry logEntry, ILogFilters filters, bool displayEnabled) { // entry details are merged with exit details return(_delayedService.HandleMethodEntry(logEntry, displayEnabled)); }
public string FormatException(int threadId, int level, int lineNo, ExceptionTrace logEntry, ILogFilters filters) { return string.Format("[Exception] {0} {1}", this.FormatTime(logEntry.Time), logEntry.Message); }
private Func<DateTime, string> CreateMethodExitLineGenerator(MethodExit logEntry, ILogFilters filters) { var returnValue = (logEntry.ReturnRecorded && !filters.HideMethodReturnValue) ? "(" + logEntry.ReturnValue + ")" : "()"; var duration = (filters.HideMethodDuration) ? "" : string.Format(" duration {0:0.####}ms", logEntry.ElapsedMs); return startTime => { var timestamp = (filters.HideTimeStampInMethod) ? "" : string.Concat(" started ", (startTime.ToString(DateTimeFormat))); return String.Concat(logEntry.MethodName, returnValue, timestamp, duration); }; }
/// <summary> /// Collates nested log calls and only returns an list of formatted log strings when a top level method exit log entry is envcountered /// </summary> /// <remarks> /// <para>This is required as, due to the nature of the single line formatter, nested logs are returned in the wrong order with the normal <see cref="FormatMethodExit"/> method.</para> /// <para>The indent must still be applied to the strings in the returned list in the <see cref="ILogOutputHandler"/>. The first item will be the top level method call.</para> /// </remarks> public IList <OrderedOutput> FormatMethodExitForSingleLineOutput(int threadId, int level, int lineNo, MethodExit logEntry, ILogFilters filters, bool displayEnabled) { Func <DateTime, String> lineBuilder = null; if (displayEnabled) { lineBuilder = this.CreateMethodExitLineGenerator(logEntry, filters); } return(_delayedService.HandleMethodExit(logEntry, lineNo, filters, lineBuilder, displayEnabled)); }
private Func <DateTime, string> CreateMethodExitLineGenerator(MethodExit logEntry, ILogFilters filters) { var returnValue = (logEntry.ReturnRecorded && !filters.HideMethodReturnValue) ? "(" + logEntry.ReturnValue + ")" : "()"; var duration = (filters.HideMethodDuration) ? "" : string.Format(" duration {0:0.####}ms", logEntry.ElapsedMs); return(startTime => { var timestamp = (filters.HideTimeStampInMethod) ? "" : string.Concat(" started ", (startTime.ToString(DateTimeFormat))); return String.Concat(logEntry.MethodName, returnValue, timestamp, duration); }); }