Skip to content

Commit

Permalink
Fix actual logging level not being synchronized with configured one
Browse files Browse the repository at this point in the history
  • Loading branch information
Banane9 committed Aug 26, 2024
1 parent 95eb157 commit 19a0bda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions MonkeyLoader/Logging/LoggingConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal set
throw new InvalidOperationException("The logging controller must only be set once!");

_loggingController = value;
_loggingController.Level = LevelKey;

EnsureDirectory();
CleanLogDirectory();
Expand All @@ -55,8 +56,6 @@ internal set
/// <inheritdoc/>
public override string Id => "Logging";

public LoggingLevel Level => LevelKey;

/// <inheritdoc/>
public override int Priority => 30;

Expand All @@ -73,6 +72,8 @@ internal set
public LoggingConfig()

Check warning on line 72 in MonkeyLoader/Logging/LoggingConfig.cs

View workflow job for this annotation

GitHub Actions / publish-docs

Non-nullable field '_loggingController' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
_currentLogFilePath = new(() => ShouldWriteLogFile ? Path.Combine(DirectoryPath, $"{FileNamePrefix}{DateTime.UtcNow.ToString(TimestampFormat, CultureInfo.InvariantCulture)}{FileExtension}") : null);

LevelKey.Changed += LevelKeyChanged;
}

public static bool TryGetTimestamp(string logFile, [NotNullWhen(true)] out DateTime? timestamp)
Expand Down Expand Up @@ -143,6 +144,12 @@ private void EnsureDirectory()
}
}

private void LevelKeyChanged(object sender, ConfigKeyChangedEventArgs<LoggingLevel> configKeyChangedEventArgs)
{
if (Controller is not null)
Controller.Level = configKeyChangedEventArgs.NewValue;
}

private void SetupLoggers()
{
LoggingHandler loggingHandlers = MissingLoggingHandler.Instance;
Expand Down
2 changes: 1 addition & 1 deletion MonkeyLoader/MonkeyLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>MonkeyLoader</Title>
<Authors>Banane9</Authors>
<Version>0.22.11-beta</Version>
<Version>0.22.12-beta</Version>
<Description>A convenience and extendability focused mod loader using NuGet packages.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand Down

0 comments on commit 19a0bda

Please sign in to comment.