mirror of https://github.com/abpframework/abp.git
7 changed files with 63 additions and 20 deletions
@ -1,14 +1,34 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
namespace Volo.Abp.Logging; |
namespace Volo.Abp.Logging; |
||||
|
|
||||
public class DefaultInitLoggerFactory : IInitLoggerFactory |
public class DefaultInitLoggerFactory : IInitLoggerFactory |
||||
{ |
{ |
||||
private readonly Dictionary<Type, object> _cache = []; |
private readonly Dictionary<Type, object> _cache = []; |
||||
|
private readonly List<List<AbpInitLogEntry>> _entryLists = []; |
||||
|
|
||||
public virtual IInitLogger<T> Create<T>() |
public virtual IInitLogger<T> Create<T>() |
||||
{ |
{ |
||||
return (IInitLogger<T>)_cache.GetOrAdd(typeof(T), () => new DefaultInitLogger<T>()); |
return (IInitLogger<T>)_cache.GetOrAdd(typeof(T), () => |
||||
|
{ |
||||
|
var logger = new DefaultInitLogger<T>(); |
||||
|
_entryLists.Add(logger.Entries); |
||||
|
return logger; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public virtual List<AbpInitLogEntry> GetAllEntries() |
||||
|
{ |
||||
|
return _entryLists.SelectMany(l => l).ToList(); |
||||
|
} |
||||
|
|
||||
|
public virtual void ClearAllEntries() |
||||
|
{ |
||||
|
foreach (var list in _entryLists) |
||||
|
{ |
||||
|
list.Clear(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,6 +1,12 @@ |
|||||
namespace Volo.Abp.Logging; |
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.Logging; |
||||
|
|
||||
public interface IInitLoggerFactory |
public interface IInitLoggerFactory |
||||
{ |
{ |
||||
IInitLogger<T> Create<T>(); |
IInitLogger<T> Create<T>(); |
||||
|
|
||||
|
List<AbpInitLogEntry> GetAllEntries(); |
||||
|
|
||||
|
void ClearAllEntries(); |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue