Esempio n. 1
0
 public void Render(Message message, Identities source)
 {
     _writerProvider.Value.WriteLine("<tr class='item {0}'>", message.Level);
     _writerProvider.Value.WriteLine("<td>{0}</td>", message.Level);
     _writerProvider.Value.WriteLine("<td>{0}</td>", string.Join(" -> ", source.Items.Select(id => id.Value).ToArray()));
     _writerProvider.Value.WriteLine("<td><pre>{0}</pre></td>", message.Text);
     _writerProvider.Value.WriteLine("</tr>");
 }
Esempio n. 2
0
 public void Render(Message message, Identities source)
 {
     Messages.Add(new Tuple<Message, Identities>(message, source));
 }
        public void Render(Message message, Identities source)
        {
            lock (_lockObject)
            {
                var level = message.Level;

                if (_lastSource == null || !Equals(_lastSource, source))
                {
                    for (int index = 0; index < source.Items.Length; index++)
                    {
                        Identity identity = source.Items[index];

                        WriteColored("[", ConsoleColor.DarkMagenta);
                        WriteColored(identity.Value, ConsoleColor.DarkMagenta);
                        WriteColored("]", ConsoleColor.DarkMagenta);

                        if (index < source.Items.Length - 1)
                        {
                            WriteColored("->", ConsoleColor.DarkCyan);
                        }
                    }

                    Console.WriteLine();
                }

                var lines = message.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();
                var procesedLines = new List<string>();

                const int fullIndentSize = 8;

                var maxWidth = _consoleWidth - fullIndentSize - 1;
                foreach (var line in lines)
                {
                    var currentLine = line;
                    while (currentLine.Length > maxWidth)
                    {
                        procesedLines.Add(currentLine.Substring(0, maxWidth));
                        currentLine = currentLine.Substring(maxWidth);
                    }

                    procesedLines.Add(currentLine);
                }

                if (procesedLines.Count > 0)
                {
                    var levelString = " " + level.ToString().ToUpper();
                    WriteColored(levelString, ConsoleColor.DarkGray);
                    Console.Write(new string(' ', fullIndentSize - levelString.Length));

                    WriteColored(procesedLines[0], GetColorForLevel(level));
                    Console.WriteLine();

                    if (procesedLines.Count > 1)
                    {
                        for (int i = 1; i < procesedLines.Count; i++)
                        {
                            Console.Write(new string(' ', fullIndentSize));
                            WriteColored(procesedLines[i], GetColorForLevel(level));
                            Console.WriteLine();
                        }
                    }
                }
                else
                {
                    Console.WriteLine();
                }

                _lastSource = source;
            }
        }
Esempio n. 4
0
 public void Render(Message message, Identities source)
 {
     Console.WriteLine("[{0}] - [{1}] - {2}", string.Join(" -> ", source.Items.Select(id => id.Value).ToArray()), message.Level, message.Text);
 }