Browse Source

Refactor InitLogger to flush all categories and address review feedback

- WriteInitLogs now uses ILoggerFactory to flush all InitLogger
  categories with their original category name instead of only
  flushing AbpApplicationBase
- Add CategoryName to AbpInitLogEntry, recorded automatically by
  DefaultInitLogger<T> using typeof(T).FullName
- Add GetAllEntries/ClearAllEntries to IInitLoggerFactory interface
- Add GetReferencedAssemblies filter to skip non-ABP assemblies
- Handle ReflectionTypeLoadException separately from other exceptions
- Add CategoryName null/empty fallback in WriteInitLogs
- Skip DisablePropertyInjection types from orphaned module detection
pull/25223/head
maliming 4 months ago
parent
commit
c377fd9544
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs
  2. 4
      framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs
  3. 5
      framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs

2
framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs

@ -112,7 +112,7 @@ public static class AbpRegistrationBuilderExtensions
registrationBuilder = registrationBuilder.PropertiesAutowired(new AbpPropertySelector(false));
}
}
else
else if (implementationType.GetCustomAttributes(typeof(DisablePropertyInjectionAttribute), true).IsNullOrEmpty())
{
nonModuleAssemblies?.Add(implementationType.Assembly);
}

4
framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs

@ -417,6 +417,10 @@ public static class AutofacRegistration
{
types = assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
types = ex.Types.Where(t => t != null).ToArray()!;
}
catch (Exception)
{
continue;

5
framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs

@ -138,7 +138,10 @@ public abstract class AbpApplicationBase : IAbpApplication
foreach (var entry in initLoggerFactory.GetAllEntries())
{
var logger = loggerFactory.CreateLogger(entry.CategoryName);
var categoryName = string.IsNullOrEmpty(entry.CategoryName)
? nameof(AbpApplicationBase)
: entry.CategoryName;
var logger = loggerFactory.CreateLogger(categoryName);
logger.Log(entry.LogLevel, entry.EventId, entry.State, entry.Exception, entry.Formatter);
}

Loading…
Cancel
Save