Skip to content

Commit 13c8ae8

Browse files
authored
Merge pull request #358 from nblumhardt/tidy-health-output
Only include detailed HTTP diagnostics in `node health` output when `--verbose` is set
2 parents cafc038 + dc131b4 commit 13c8ae8

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/SeqCli/Cli/Commands/Node/HealthCommand.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ protected override async Task<int> Run()
5454
try
5555
{
5656
var response = await connection.Client.HttpClient.GetAsync("health");
57-
Console.WriteLine($"HTTP {response.Version} {((int)response.StatusCode).ToString(CultureInfo.InvariantCulture)} {response.ReasonPhrase}");
57+
Log.Information("HTTP {HttpVersion} {StatusCode} {ReasonPhrase}", response.Version, (int)response.StatusCode, response.ReasonPhrase);
58+
5859
foreach (var (key, values) in response.Headers.Concat(response.Content.Headers))
5960
foreach (var value in values)
6061
{
61-
Console.WriteLine($"{key}: {value}");
62+
Log.Information("{HeaderName}: {HeaderValue}", key, value);
6263
}
64+
6365
Console.WriteLine(await response.Content.ReadAsStringAsync());
66+
6467
return response.IsSuccessStatusCode ? 0 : 1;
6568
}
6669
catch (Exception ex)

test/SeqCli.EndToEnd/Node/NodeDemoteTestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace SeqCli.EndToEnd.Node;
88

9-
[CliTestCase(MinimumApiVersion = "2021.3.6410")]
9+
[CliTestCase]
1010
public class NodeDemoteTestCase: ICliTestCase
1111
{
1212
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner)

test/SeqCli.EndToEnd/Node/NodeHealthTestCase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
namespace SeqCli.EndToEnd.Node;
88

9-
[CliTestCase(MinimumApiVersion = "2021.3.6410")]
9+
[CliTestCase]
1010
public class NodeHealthTestCase: ICliTestCase
1111
{
1212
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner)
1313
{
1414
var exit = runner.Exec("node health");
1515
Assert.Equal(0, exit);
16-
Assert.StartsWith("HTTP 1.1 200 OK", runner.LastRunProcess!.Output);
16+
Assert.StartsWith("{\"status\":", runner.LastRunProcess!.Output);
1717
return Task.CompletedTask;
1818
}
1919
}

test/SeqCli.EndToEnd/Node/NodeListTestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace SeqCli.EndToEnd.Node;
88

9-
[CliTestCase(MinimumApiVersion = "2021.3.6410")]
9+
[CliTestCase]
1010
public class NodeListTestCase: ICliTestCase
1111
{
1212
public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner)

0 commit comments

Comments
 (0)