Make filterLevel changeable at runtime
This commit is contained in:
parent
13ba0fedea
commit
775b8e3a6a
@ -7,7 +7,7 @@
|
||||
<Authors>Glax</Authors>
|
||||
<RepositoryUrl>https://git.bernloehr.eu/glax/GlaxLogger</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<Version>1.0.3</Version>
|
||||
<Version>1.0.4</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -5,13 +5,12 @@ namespace GlaxLogger;
|
||||
|
||||
public class Logger : ILogger, IDisposable, IAsyncDisposable
|
||||
{
|
||||
private readonly LogLevel _filterLevel;
|
||||
private LogLevel _filterLevel;
|
||||
private readonly FileStream _allMessageLogfile, _filteredLogfile;
|
||||
private readonly ConsoleColor _defaultForegroundColor = Console.ForegroundColor;
|
||||
private readonly ConsoleColor _defaultBackgroundColor = Console.BackgroundColor;
|
||||
private readonly TextWriter _consoleOut;
|
||||
|
||||
|
||||
public Logger(LogLevel filteredLevel = LogLevel.Warning, string? outputFolderPath = null, TextWriter? consoleOut = null)
|
||||
{
|
||||
this._filterLevel = filteredLevel;
|
||||
@ -46,6 +45,12 @@ public class Logger : ILogger, IDisposable, IAsyncDisposable
|
||||
return logLevel >= _filterLevel;
|
||||
}
|
||||
|
||||
public void UpdateLogLevel(LogLevel filterLevel)
|
||||
{
|
||||
this._filterLevel = filterLevel;
|
||||
Log(LogLevel.None, new EventId(), $"Change LogLevel to {filterLevel}", null, (s, exception) => s);
|
||||
}
|
||||
|
||||
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
|
||||
{
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user