From 726cba7b3df7e34bb0e4509192bd08989515e768 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 26 May 2025 15:12:43 +1000 Subject: [PATCH 1/2] Fall back to paged searching automatically when WebSockets are not supported (widens compat with earlier Seq versions) --- seqcli.sln | 6 --- src/SeqCli/Cli/Commands/SearchCommand.cs | 45 ++++++++++++------- .../Cli/Features/OutputFormatFeature.cs | 4 +- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/seqcli.sln b/seqcli.sln index 2bc38226..a1b436f8 100644 --- a/seqcli.sln +++ b/seqcli.sln @@ -8,14 +8,8 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519F-4DD5-9E94-CCC43E3DF624}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore - appveyor.yml = appveyor.yml - Build.ps1 = Build.ps1 LICENSE = LICENSE README.md = README.md - setup.sh = setup.sh - Build.Docker.ps1 = Build.Docker.ps1 - docker-publish.ps1 = docker-publish.ps1 - Setup.ps1 = Setup.ps1 CONTRIBUTING.md = CONTRIBUTING.md ci.global.json = ci.global.json EndProjectSection diff --git a/src/SeqCli/Cli/Commands/SearchCommand.cs b/src/SeqCli/Cli/Commands/SearchCommand.cs index 254c52f8..001bca4d 100644 --- a/src/SeqCli/Cli/Commands/SearchCommand.cs +++ b/src/SeqCli/Cli/Commands/SearchCommand.cs @@ -85,23 +85,36 @@ protected override async Task Run() if (!string.IsNullOrWhiteSpace(_filter)) filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression; - var search = _noWebSockets ? - connection.Events.PagedEnumerateAsync(null, - _signal.Signal, - filter, - _count, - fromDateUtc: _range.Start, - toDateUtc: _range.End, - trace: _trace) : - connection.Events.EnumerateAsync(null, - _signal.Signal, - filter, - _count, - fromDateUtc: _range.Start, - toDateUtc: _range.End, - trace: _trace); + try + { + if (!_noWebSockets) + { + await foreach (var evt in connection.Events.EnumerateAsync(null, + _signal.Signal, + filter, + _count, + fromDateUtc: _range.Start, + toDateUtc: _range.End, + trace: _trace)) + { + output.Write(ToSerilogEvent(evt)); + } + + return 0; + } + } + catch (NotSupportedException nse) + { + Log.Information(nse, "WebSockets not supported; falling back to paged search"); + } - await foreach (var evt in search) + await foreach (var evt in connection.Events.PagedEnumerateAsync(null, + _signal.Signal, + filter, + _count, + fromDateUtc: _range.Start, + toDateUtc: _range.End, + trace: _trace)) { output.Write(ToSerilogEvent(evt)); } diff --git a/src/SeqCli/Cli/Features/OutputFormatFeature.cs b/src/SeqCli/Cli/Features/OutputFormatFeature.cs index bfad25a3..b1017387 100644 --- a/src/SeqCli/Cli/Features/OutputFormatFeature.cs +++ b/src/SeqCli/Cli/Features/OutputFormatFeature.cs @@ -35,9 +35,9 @@ class OutputFormatFeature : CommandFeature public const string DefaultOutputTemplate = "[{Timestamp:o} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}"; - public static readonly ConsoleTheme DefaultTheme = SystemConsoleTheme.Literate; public static readonly ConsoleTheme DefaultAnsiTheme = AnsiConsoleTheme.Code; - static readonly TemplateTheme DefaultTemplateTheme = TemplateTheme.Literate; + public static readonly ConsoleTheme DefaultTheme = OperatingSystem.IsWindows() ? SystemConsoleTheme.Literate : DefaultAnsiTheme; + static readonly TemplateTheme DefaultTemplateTheme = TemplateTheme.Code; bool _json, _noColor, _forceColor; From d5385f1f4140f9a1746350e9e15b0e1cc2e22553 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 26 May 2025 15:53:13 +1000 Subject: [PATCH 2/2] Disable output colors in dashboard rendering test case --- test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs b/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs index 23705c45..4c29aff9 100644 --- a/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs +++ b/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs @@ -19,7 +19,7 @@ public Task ExecuteAsync( var id = runner.LastRunProcess.Output.Split(' ')[0]; - exit = runner.Exec("dashboard render", $"-i {id} -c \"All Events\" --last 1d --by 1h"); + exit = runner.Exec("dashboard render", $"-i {id} -c \"All Events\" --last 1d --by 1h --no-color"); Assert.Equal(0, exit); var lines = new StringReader(runner.LastRunProcess.Output);