Ejemplo n.º 1
0
            protected override async Task <CollectionRuleActionResult> ExecuteCoreAsync(
                TaskCompletionSource <object> startCompletionSource,
                CancellationToken token)
            {
                TimeSpan duration      = Options.Duration.GetValueOrDefault(TimeSpan.Parse(CollectLogsOptionsDefaults.Duration));
                bool     useAppFilters = Options.UseAppFilters.GetValueOrDefault(CollectLogsOptionsDefaults.UseAppFilters);
                LogLevel defaultLevel  = Options.DefaultLevel.GetValueOrDefault(CollectLogsOptionsDefaults.DefaultLevel);
                Dictionary <string, LogLevel?> filterSpecs = Options.FilterSpecs;
                string    egressProvider = Options.Egress;
                LogFormat logFormat      = Options.Format.GetValueOrDefault(CollectLogsOptionsDefaults.Format);

                var settings = new EventLogsPipelineSettings()
                {
                    Duration      = duration,
                    LogLevel      = defaultLevel,
                    UseAppFilters = useAppFilters,
                    FilterSpecs   = filterSpecs
                };

                string fileName    = LogsUtilities.GenerateLogsFileName(EndpointInfo);
                string contentType = LogsUtilities.GetLogsContentType(logFormat);

                KeyValueLogScope scope = Utils.CreateArtifactScope(Utils.ArtifactType_Logs, EndpointInfo);

                EgressOperation egressOperation = new EgressOperation(
                    (outputStream, token) => LogsUtilities.CaptureLogsAsync(startCompletionSource, logFormat, EndpointInfo, settings, outputStream, token),
                    egressProvider,
                    fileName,
                    EndpointInfo,
                    contentType,
                    scope);

                ExecutionResult <EgressResult> result = await egressOperation.ExecuteAsync(_serviceProvider, token);

                string logsFilePath = result.Result.Value;

                return(new CollectionRuleActionResult()
                {
                    OutputValues = new Dictionary <string, string>(StringComparer.Ordinal)
                    {
                        { CollectionRuleActionConstants.EgressPathOutputValueName, logsFilePath }
                    }
                });
            }
Ejemplo n.º 2
0
        private Task <ActionResult> StartLogs(
            IProcessInfo processInfo,
            EventLogsPipelineSettings settings,
            string egressProvider)
        {
            LogFormat?format = ComputeLogFormat(Request.GetTypedHeaders().Accept);

            if (null == format)
            {
                return(Task.FromResult <ActionResult>(this.NotAcceptable()));
            }

            string fileName    = LogsUtilities.GenerateLogsFileName(processInfo.EndpointInfo);
            string contentType = LogsUtilities.GetLogsContentType(format.Value);

            return(Result(
                       Utilities.ArtifactType_Logs,
                       egressProvider,
                       (outputStream, token) => LogsUtilities.CaptureLogsAsync(null, format.Value, processInfo.EndpointInfo, settings, outputStream, token),
                       fileName,
                       contentType,
                       processInfo.EndpointInfo,
                       format != LogFormat.PlainText));
        }