bool IsPrintable(ActivityElement element)
        {
            if (element.Status == ActivityStatus.Pending || element.Status == ActivityStatus.Running)
                return false;

            if (printed.Contains(element.Id))
                return false;

            printed.Add(element.Id);
            return true;
        }
        void RenderToConsole(ActivityElement element, ILog log, string indent)
        {
            if (!IsPrintable(element))
                return;

            if (element.Status == ActivityStatus.Success)
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            else if (element.Status == ActivityStatus.SuccessWithWarning)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
            }
            else if (element.Status == ActivityStatus.Failed)
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            Console.WriteLine("{0}         {1}: {2}", indent, element.Status, element.Name);
            Console.ResetColor();

            foreach (var logEntry in element.LogElements)
            {
                if (logEntry.Category == "Error" || logEntry.Category == "Fatal")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                else if (logEntry.Category == "Warning")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }

                log.InfoFormat("{0}{1,-8}   {2}", indent, logEntry.Category, LineSplitter.Split(indent + new string(' ', 11), logEntry.MessageText));
                Console.ResetColor();
            }

            foreach (var child in element.Children)
            {
                RenderToConsole(child, log, indent + "  ");
            }
        }
        void RenderToTeamCity(ActivityElement element, ILog log)
        {
            if (!IsPrintable(element))
                return;

            var blockName = element.Status + ": " + element.Name;

            log.ServiceMessage("blockOpened", new { name = blockName });

            foreach (var logEntry in element.LogElements)
            {
                var lines = logEntry.MessageText.Split('\n').Where(l => !string.IsNullOrWhiteSpace(l)).ToArray();
                foreach (var line in lines)
                {
                    log.ServiceMessage("message", new { text = line, status = ConvertToTeamCityMessageStatus(logEntry.Category) });
                }
            }

            foreach (var child in element.Children)
            {
                RenderToTeamCity(child, log);
            }

            log.ServiceMessage("blockClosed", new { name = blockName });
        }
        void RenderToVSTS(ActivityElement element, ILogger log, string indent)
        {
            if (!IsPrintable(element))
                return;

            log.Information("{Indent:l}         {Status:l}: {Name:l}", indent, element.Status, element.Name);

            foreach (var logEntry in element.LogElements)
            {
                log.Information("{Category,-8:l}{Indent:l}   {Message:l}", logEntry.Category, logEntry.MessageText);
            }

            foreach (var child in element.Children)
            {
                RenderToVSTS(child, log, indent + "  ");
            }
        }