Skip to content

Commit 57defa6

Browse files
committed
AppDefinition LogLevel updated
1 parent efe05b4 commit 57defa6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Calabonga.AspNetCore.AppDefinitions/AppDefinitionExtensions.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.AspNetCore.Builder;
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.Extensions.DependencyInjection;
4-
using Microsoft.Extensions.Hosting;
54
using Microsoft.Extensions.Logging;
65

76
namespace Calabonga.AspNetCore.AppDefinitions;
@@ -27,7 +26,7 @@ public static void AddDefinitions(this IServiceCollection source, WebApplication
2726
var types = entryPoint.Assembly.ExportedTypes.Where(x => !x.IsAbstract && typeof(IAppDefinition).IsAssignableFrom(x));
2827
var instances = types.Select(Activator.CreateInstance).Cast<IAppDefinition>().ToList();
2928
var instancesOrdered = instances.Where(x => x.Enabled).OrderBy(x => x.OrderIndex).ToList();
30-
if (builder.Environment.IsDevelopment())
29+
if (logger.IsEnabled(LogLevel.Debug))
3130
{
3231
logger.LogDebug(@"[AppDefinitions] Founded: {AppDefinitionsCountTotal}. Enabled: {AppDefinitionsCountEnabled}", instances.Count, instancesOrdered.Count);
3332
logger.LogDebug(@"[AppDefinitions] Registered [{Total}]", string.Join(", ", instancesOrdered.Select(x => x.GetType().Name).ToArray()));
@@ -54,10 +53,10 @@ public static void UseDefinitions(this WebApplication source)
5453
var environment = source.Services.GetRequiredService<IWebHostEnvironment>();
5554
var definitions = source.Services.GetRequiredService<IReadOnlyCollection<IAppDefinition>>();
5655
var instancesOrdered = definitions.Where(x => x.Enabled).OrderBy(x => x.OrderIndex).ToList();
57-
56+
5857
instancesOrdered.ForEach(x => x.ConfigureApplication(source));
5958

60-
if (environment.IsDevelopment())
59+
if (logger.IsEnabled(LogLevel.Debug))
6160
{
6261
logger.LogDebug("Total application definitions configured {Count}", instancesOrdered.Count);
6362
}

src/Calabonga.AspNetCore.AppDefinitions/Calabonga.AspNetCore.AppDefinitions.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
88
<Title>Calabonga.AspNetCore.AppDefinitions</Title>
9-
<Version>1.2.1</Version>
9+
<Version>1.2.2</Version>
1010
<Authors>Calabonga</Authors>
1111
<Company>Calabonga Soft</Company>
1212
<Product>Calabonga.AspNetCore.AppDefinitions</Product>
@@ -18,7 +18,7 @@
1818
<RepositoryUrl>https://github.com/Calabonga/Calabonga.AspNetCore.AppDefinitions</RepositoryUrl>
1919
<RepositoryType>git</RepositoryType>
2020
<PackageTags>calabonga;architecture;definitions;minimal-api;nimble-framework</PackageTags>
21-
<PackageReleaseNotes>AppDefinition setter added for Enable property</PackageReleaseNotes>
21+
<PackageReleaseNotes>AppDefinition LogLevel updated</PackageReleaseNotes>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2323
</PropertyGroup>
2424

0 commit comments

Comments
 (0)