public Task <ActionResult> Logs( ProcessFilter?processFilter, [FromQuery][Range(-1, int.MaxValue)] int durationSeconds = 30, [FromQuery] LogLevel level = LogLevel.Debug) { TimeSpan duration = ConvertSecondsToTimeSpan(durationSeconds); return(this.InvokeService(async() => { IProcessInfo processInfo = await _diagnosticServices.GetProcessAsync(processFilter, HttpContext.RequestAborted); LogFormat format = ComputeLogFormat(Request.GetTypedHeaders().Accept); if (format == LogFormat.None) { return this.NotAcceptable(); } string contentType = (format == LogFormat.EventStream) ? ContentTypeEventStream : ContentTypeNdJson; string downloadName = (format == LogFormat.EventStream) ? null : FormattableString.Invariant($"{GetFileNameTimeStampUtcNow()}_{processInfo.ProcessId}.txt"); return new OutputStreamResult(async(outputStream, token) => { await _diagnosticServices.StartLogs(outputStream, processInfo, duration, format, level, token); }, contentType, downloadName); })); }
public ActionResult Logs(int?pid, [FromQuery][Range(-1, int.MaxValue)] int durationSeconds = 30) { TimeSpan duration = ConvertSecondsToTimeSpan(durationSeconds); return(InvokeService(() => { int pidValue = _diagnosticServices.ResolveProcess(pid); return new OutputStreamResult(async(outputStream, token) => { await _diagnosticServices.StartLogs(outputStream, pidValue, duration, token); }, "application/x-ndjson", FormattableString.Invariant($"{Guid.NewGuid()}.txt")); })); }
public ActionResult Logs(int?pid, [FromQuery][Range(-1, int.MaxValue)] int durationSeconds = 30, [FromQuery] LogLevel level = LogLevel.Debug) { TimeSpan duration = ConvertSecondsToTimeSpan(durationSeconds); return(this.InvokeService(() => { int pidValue = _diagnosticServices.ResolveProcess(pid); LogFormat format = ComputeLogFormat(Request.GetTypedHeaders().Accept); if (format == LogFormat.None) { return this.NotAcceptable(); } string contentType = (format == LogFormat.EventStream) ? ContentTypeEventStream : ContentTypeNdJson; string downloadName = (format == LogFormat.EventStream) ? null : FormattableString.Invariant($"{GetFileNameTimeStampUtcNow()}_{pidValue}.txt"); return new OutputStreamResult(async(outputStream, token) => { await _diagnosticServices.StartLogs(outputStream, pidValue, duration, format, level, token); }, contentType, downloadName); })); }