Skip to content

Commit

Permalink
Reduce redundant logs when setting flags
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Jul 24, 2023
1 parent d186126 commit 6547118
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Bloxstrap/FastFlagManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@ public void SetValue(string key, object? value)
{
if (value is null)
{
if (Prop.ContainsKey(key))
App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending");

Prop.Remove(key);
App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending");
}
else
{
if (Prop.ContainsKey(key))
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' from '{Prop[key]}' to '{value}' is pending");
else
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' to '{value}' is pending");

Prop[key] = value.ToString()!;
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' to '{value}' is pending");
}
}

Expand Down Expand Up @@ -157,13 +163,13 @@ public void SetPresetEnum(string prefix, string target, object? value)

public string GetPresetEnum(IReadOnlyDictionary<string, string> mapping, string prefix, string value)
{
foreach (var mode in mapping)
foreach (var pair in mapping)
{
if (mode.Key == mapping.First().Key)
if (pair.Value == "None")
continue;

if (App.FastFlags.GetPreset($"{prefix}.{mode.Value}") == value)
return mode.Key;
if (GetPreset($"{prefix}.{pair.Value}") == value)
return pair.Key;
}

return mapping.First().Key;
Expand Down

0 comments on commit 6547118

Please sign in to comment.