Skip to content

Commit c15f974

Browse files
authored
Merge pull request #394 from nblumhardt/websocket-fallback
Fall back to paged searching automatically when WebSockets are not supported
2 parents 687b71e + d5385f1 commit c15f974

File tree

4 files changed

+32
-25
lines changed

4 files changed

+32
-25
lines changed

seqcli.sln

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,8 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519F-4DD5-9E94-CCC43E3DF624}"
99
ProjectSection(SolutionItems) = preProject
1010
.gitignore = .gitignore
11-
appveyor.yml = appveyor.yml
12-
Build.ps1 = Build.ps1
1311
LICENSE = LICENSE
1412
README.md = README.md
15-
setup.sh = setup.sh
16-
Build.Docker.ps1 = Build.Docker.ps1
17-
docker-publish.ps1 = docker-publish.ps1
18-
Setup.ps1 = Setup.ps1
1913
CONTRIBUTING.md = CONTRIBUTING.md
2014
ci.global.json = ci.global.json
2115
EndProjectSection

src/SeqCli/Cli/Commands/SearchCommand.cs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,36 @@ protected override async Task<int> Run()
8585
if (!string.IsNullOrWhiteSpace(_filter))
8686
filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression;
8787

88-
var search = _noWebSockets ?
89-
connection.Events.PagedEnumerateAsync(null,
90-
_signal.Signal,
91-
filter,
92-
_count,
93-
fromDateUtc: _range.Start,
94-
toDateUtc: _range.End,
95-
trace: _trace) :
96-
connection.Events.EnumerateAsync(null,
97-
_signal.Signal,
98-
filter,
99-
_count,
100-
fromDateUtc: _range.Start,
101-
toDateUtc: _range.End,
102-
trace: _trace);
88+
try
89+
{
90+
if (!_noWebSockets)
91+
{
92+
await foreach (var evt in connection.Events.EnumerateAsync(null,
93+
_signal.Signal,
94+
filter,
95+
_count,
96+
fromDateUtc: _range.Start,
97+
toDateUtc: _range.End,
98+
trace: _trace))
99+
{
100+
output.Write(ToSerilogEvent(evt));
101+
}
102+
103+
return 0;
104+
}
105+
}
106+
catch (NotSupportedException nse)
107+
{
108+
Log.Information(nse, "WebSockets not supported; falling back to paged search");
109+
}
103110

104-
await foreach (var evt in search)
111+
await foreach (var evt in connection.Events.PagedEnumerateAsync(null,
112+
_signal.Signal,
113+
filter,
114+
_count,
115+
fromDateUtc: _range.Start,
116+
toDateUtc: _range.End,
117+
trace: _trace))
105118
{
106119
output.Write(ToSerilogEvent(evt));
107120
}

src/SeqCli/Cli/Features/OutputFormatFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class OutputFormatFeature : CommandFeature
3535
public const string DefaultOutputTemplate =
3636
"[{Timestamp:o} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}";
3737

38-
public static readonly ConsoleTheme DefaultTheme = SystemConsoleTheme.Literate;
3938
public static readonly ConsoleTheme DefaultAnsiTheme = AnsiConsoleTheme.Code;
40-
static readonly TemplateTheme DefaultTemplateTheme = TemplateTheme.Literate;
39+
public static readonly ConsoleTheme DefaultTheme = OperatingSystem.IsWindows() ? SystemConsoleTheme.Literate : DefaultAnsiTheme;
40+
static readonly TemplateTheme DefaultTemplateTheme = TemplateTheme.Code;
4141

4242
bool _json, _noColor, _forceColor;
4343

test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Task ExecuteAsync(
1919

2020
var id = runner.LastRunProcess.Output.Split(' ')[0];
2121

22-
exit = runner.Exec("dashboard render", $"-i {id} -c \"All Events\" --last 1d --by 1h");
22+
exit = runner.Exec("dashboard render", $"-i {id} -c \"All Events\" --last 1d --by 1h --no-color");
2323
Assert.Equal(0, exit);
2424

2525
var lines = new StringReader(runner.LastRunProcess.Output);

0 commit comments

Comments
 (0)