Example #1
0
        /// <summary>
        /// Writes the given record to the console and highlights certain parts of the line.
        /// </summary>
        /// <param name="record">The record to write to the console.</param>
        protected void WriteConsoleRecord(string record)
        {
            if (!Highlighters.Any())
            {
                return;
            }

            // Create base highlighter collection instance
            var highlights = Highlighters[0].GetHighlights(ref record);

            // Combine all the other collections with the first
            for (int i = 1; i < Highlighters.Count; i++)
            {
                highlights.AddRange(Highlighters[i].GetHighlights(ref record));
            }

            // Write the record using the highlight colors
            highlights.Print();
        }
Example #2
0
        public void Initialise()
        {
            Debug.Assert(!Highlighters.Any(), "Should not have any contents at initialisation");

            Highlighters.Add(new StandardHighlighter("Trace", true, LogEntryField.Type, MatchMode.Exact, "TRACE", new HighlighterStyle {
                Background = Colors.LightGray
            }) as T);
            Highlighters.Add(new StandardHighlighter("Debug", true, LogEntryField.Type, MatchMode.Exact, "DEBUG", new HighlighterStyle {
                Background = Colors.LightGreen
            }) as T);
            Highlighters.Add(new StandardHighlighter("Info", true, LogEntryField.Type, MatchMode.Exact, "INFO", new HighlighterStyle {
                Foreground = Colors.White, Background = Colors.Blue
            }) as T);
            Highlighters.Add(new StandardHighlighter("Warn", true, LogEntryField.Type, MatchMode.Exact, "WARN", new HighlighterStyle {
                Background = Colors.Yellow
            }) as T);
            Highlighters.Add(new StandardHighlighter("Error", true, LogEntryField.Type, MatchMode.Exact, "ERROR", new HighlighterStyle {
                Foreground = Colors.White, Background = Colors.Red
            }) as T);
            Highlighters.Add(new StandardHighlighter("Fatal", true, LogEntryField.Type, MatchMode.Exact, "FATAL", new HighlighterStyle {
                Foreground = Colors.Yellow, Background = Colors.Black
            }) as T);
        }