-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixing log settings that have no namespace (#1014)
- removing duplicates - updating settings from factory - making sure classes with no namespace save/load correctly
- Loading branch information
1 parent
88badd6
commit ead317f
Showing
4 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using Mirage.Logging; | ||
using UnityEngine; | ||
|
||
namespace Mirage.EditorScripts.Logging | ||
{ | ||
/// <summary> | ||
/// Removes duplicates and updates log settings from LogFactory | ||
/// </summary> | ||
public class LogSettingChecker | ||
{ | ||
readonly LogSettingsSO settings; | ||
readonly HashSet<string> duplicateChecker = new HashSet<string>(); | ||
|
||
public LogSettingChecker(LogSettingsSO settings) | ||
{ | ||
this.settings = settings; | ||
} | ||
|
||
public void Refresh() | ||
{ | ||
duplicateChecker.Clear(); | ||
RemoveDuplicates(); | ||
AddNewFromFactory(); | ||
} | ||
|
||
void RemoveDuplicates() | ||
{ | ||
for (int i = 0; i < settings.LogLevels.Count; i++) | ||
{ | ||
bool added = duplicateChecker.Add(settings.LogLevels[i].FullName); | ||
// is duplicate, remove it | ||
if (!added) | ||
{ | ||
settings.LogLevels.RemoveAt(i); | ||
i--; | ||
} | ||
} | ||
} | ||
|
||
void AddNewFromFactory() | ||
{ | ||
// try add new types | ||
foreach (KeyValuePair<string, ILogger> logger in LogFactory.Loggers) | ||
{ | ||
bool added = duplicateChecker.Add(logger.Key); | ||
// is new, add it | ||
if (added) | ||
{ | ||
settings.LogLevels.Add(new LogSettingsSO.LoggerSettings(logger.Key, logger.Value.filterLogType)); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters