private static async Task DisplayDeploymentLog()

in src/Cli/func/Helpers/KuduLiteDeploymentHelpers.cs [146:184]


        private static async Task<DateTime> DisplayDeploymentLog(HttpClient client, Site functionApp, string id, DateTime lastUpdate, Uri innerUrl = null, StringBuilder innerLogger = null)
        {
            string logUrl = innerUrl != null ? innerUrl.ToString() : (functionApp.IsFlex ? $"/api/deployments/{id}/log" : $"/deployments/{id}/log");
            StringBuilder sbLogger = innerLogger != null ? innerLogger : new StringBuilder();

            var deploymentLogs = await InvokeRequest<List<DeploymentLogResponse>>(client, HttpMethod.Get, logUrl);
            var newLogs = deploymentLogs.Where(deploymentLog => deploymentLog.LogTime > lastUpdate || !string.IsNullOrEmpty(deploymentLog.DetailsUrlString));
            DateTime currentLogDatetime = lastUpdate;

            foreach (var log in newLogs)
            {
                // Filter out details_url log
                if (log.LogTime > lastUpdate)
                {
                    sbLogger.AppendLine(log.Message);
                }

                // Recursively log details_url from scm/api/deployments/xxx/log endpoint
                if (!string.IsNullOrEmpty(log.DetailsUrlString) && Uri.TryCreate(log.DetailsUrlString, UriKind.Absolute, out Uri detailsUrl))
                {
                    DateTime innerLogDatetime = await DisplayDeploymentLog(client, functionApp, id, currentLogDatetime, detailsUrl, sbLogger);
                    currentLogDatetime = innerLogDatetime > currentLogDatetime ? innerLogDatetime : currentLogDatetime;
                }
            }

            if (newLogs.LastOrDefault() != null)
            {
                DateTime lastLogDatetime = newLogs.Last().LogTime;
                currentLogDatetime = lastLogDatetime > currentLogDatetime ? lastLogDatetime : currentLogDatetime;
            }

            // Report build status on the root level parser
            if (innerUrl == null && sbLogger.Length > 0)
            {
                ColoredConsole.Write(sbLogger.ToString());
            }

            return currentLogDatetime;
        }