Skip to content

Commit 9e72294

Browse files
committed
Touchup logging
1 parent a2fb516 commit 9e72294

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/Elastic.Documentation.ServiceDefaults/AppDefaultsExtensions.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,21 @@ public static TBuilder AddAppDefaults<TBuilder>(this TBuilder builder, ref strin
4646
_ = s.AddSingleton(p.CreateVersionConfiguration());
4747
configure?.Invoke(s, p);
4848
});
49+
_ = builder.Services.AddAppLogging(logLevel);
50+
51+
return builder.AddServiceDefaults();
52+
}
53+
54+
public static TServiceCollection AddAppLogging<TServiceCollection>(this TServiceCollection services, LogLevel logLevel)
55+
where TServiceCollection : IServiceCollection
56+
{
4957
services.TryAddEnumerable(ServiceDescriptor.Singleton<ConsoleFormatter, CondensedConsoleFormatter>());
5058
_ = services.AddLogging(x => x
5159
.ClearProviders()
5260
.SetMinimumLevel(logLevel)
5361
.AddConsole(c => c.FormatterName = "condensed")
5462
);
55-
56-
return builder.AddServiceDefaults();
63+
return services;
5764
}
5865

5966
private static void ProcessCommandLineArguments(ref string[] args, ref LogLevel defaultLogLevel)

tests-integration/Elastic.Assembler.IntegrationTests/AssembleFixture.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
using Aspire.Hosting;
66
using Aspire.Hosting.Testing;
7+
using Elastic.Documentation.ServiceDefaults;
78
using FluentAssertions;
9+
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.Logging;
811

912
[assembly: CaptureConsole, AssemblyFixture(typeof(Elastic.Assembler.IntegrationTests.AssembleFixture))]
1013

@@ -19,6 +22,7 @@ public class AssembleFixture : IAsyncLifetime
1922
public async ValueTask InitializeAsync()
2023
{
2124
var builder = await DistributedApplicationTestingBuilder.CreateAsync<Projects.Elastic_Documentation_Aspire>();
25+
_ = builder.Services.AddAppLogging(LogLevel.Information);
2226
DistributedApplication = await builder.BuildAsync();
2327
await DistributedApplication.StartAsync();
2428
}
@@ -34,7 +38,7 @@ public async ValueTask DisposeAsync()
3438

3539
}
3640

37-
public class DatabaseTestClass1(AssembleFixture fixture)
41+
public class DatabaseTestClass1(AssembleFixture fixture, ITestOutputHelper output)
3842
{
3943
[Fact]
4044
public async Task X()
@@ -43,6 +47,7 @@ public async Task X()
4347
.WaitForResourceHealthyAsync("DocsBuilderServeStatic", cancellationToken: TestContext.Current.CancellationToken);
4448
var client = fixture.DistributedApplication.CreateHttpClient("DocsBuilderServeStatic", "http");
4549
var root = await client.GetStringAsync("/", TestContext.Current.CancellationToken);
50+
output.WriteLine(root);
4651
_ = root.Should().NotBeNullOrEmpty();
4752
}
4853

tests-integration/Elastic.Assembler.IntegrationTests/Class1.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)