Skip to content

Commit

Permalink
fix(Logging): fixing full name not being loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed Dec 29, 2021
1 parent dfe8ac3 commit caece7e
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Assets/Mirage/Runtime/Logging/LogSettingsSO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ public class LoggerSettings
public string Namespace;

private string fullNameCache;
public string FullName => fullNameCache;
public string FullName
{
get
{
// need lazy property here because unity deserializes without using constructor
if (string.IsNullOrEmpty(fullNameCache))
fullNameCache = CreateFullName(Name, Namespace);

return fullNameCache;
}
}

static string CreateFullName(string name, string space)
{
Expand Down Expand Up @@ -105,9 +115,19 @@ public static void LoadIntoLogFactory(this LogSettingsSO settings)
return;
}

foreach (LogSettingsSO.LoggerSettings logLevel in settings.LogLevels)
for (int i = 0; i < settings.LogLevels.Count; i++)
{
ILogger logger = LogFactory.GetLogger(logLevel.FullName);
LogSettingsSO.LoggerSettings logLevel = settings.LogLevels[i];
string key = logLevel.FullName;
if (key == null)
{
settings.LogLevels.RemoveAt(i);
i--;
Debug.LogWarning("Found null key in log settings, removing item");
continue;
}

ILogger logger = LogFactory.GetLogger(key);
logger.filterLogType = logLevel.logLevel;
}
}
Expand Down

0 comments on commit caece7e

Please sign in to comment.