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));
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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;
        }
Example #6
0
        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);
        }
Example #7
0
 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));
     }
 }
Example #8
0
        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;
        }
Example #9
0
        /// <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);
        }
Example #10
0
        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;
        }
Example #11
0
        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();
        }
Example #13
0
        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;
        }
Example #15
0
        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));
        }
Example #16
0
        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);
        }
Example #17
0
        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));
            }
        }
Example #18
0
 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;
 }
Example #19
0
 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;
        }
Example #21
0
 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));
 }
Example #22
0
 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);
 }
Example #24
0
        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());
        }
Example #25
0
 public DefaultOutputHandler(ILogFilters filters)
     : this(filters, new DefaultFormatter())
 {
 }
Example #26
0
 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);
 }
Example #28
0
        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));
        }
Example #29
0
 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));
 }
Example #30
0
        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));
        }
Example #31
0
        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));
        }
Example #32
0
 public ThreadCollectionOutputHandler(ILogFilters filters) : this(filters, new DefaultFormatter())
 {
 }
Example #33
0
 public ThreadCollectionOutputHandler(ILogFilters filters, ILogFormatter formatter) : base(filters, formatter)
 {
     _threadEntries = new Dictionary <int, List <String> >(20);
 }
Example #34
0
 public static LogFiltersBuilder Create(ILogFilters copyFilters)
 {
     return(new LogFiltersBuilder(copyFilters));
 }
Example #35
0
 public static LogFiltersBuilder Create(ILogFilters copyFilters)
 {
     return new LogFiltersBuilder(copyFilters);
 }
Example #36
0
 public string FormatThread(ThreadData logEntry, ILogFilters filters)
 {
     return(_default.FormatThread(logEntry, filters));
 }
 public TextWriterOutputHandler(TextWriter writer, ILogFilters filters) : this(writer, filters, new DefaultFormatter())
 {
 }
Example #38
0
 public string FormatThread(ThreadData logEntry, ILogFilters filters)
 {
     return _default.FormatThread(logEntry, filters);
 }
 public TextWriterOutputHandler(TextWriter writer, ILogFilters filters)
     : this(writer, filters, new DefaultFormatter())
 {
 }
Example #40
0
        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)));
        }
Example #41
0
        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));
        }
Example #42
0
 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 string FormatThread(ThreadData logEntry, ILogFilters filters)
 {
     return null;
 }
Example #44
0
 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));
 }
Example #46
0
 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)));
 }
Example #47
0
 public string FormatException(int threadId, int level, int lineNo, ExceptionTrace logEntry, ILogFilters filters)
 {
     return _delayedService.HandleException(_default.FormatException(threadId, level, lineNo, logEntry, filters));
 }
Example #48
0
        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)));
        }
Example #49
0
 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 ThreadCollectionOutputHandler(ILogFilters filters)
     : this(filters, new DefaultFormatter())
 {
 }
Example #51
0
 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));
 }
Example #52
0
 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);
 }
Example #53
0
        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);
                };
        }
Example #54
0
        /// <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));
        }
Example #55
0
        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);
            });
        }
Example #56
0
 public DefaultOutputHandler(ILogFilters filters) : this(filters, new DefaultFormatter())
 {
 }