Skip to content

Commit 74e64b0

Browse files
committed
fix(log,config) : Using default log levels if config file doesn't exist
User were met with initialize errors when log level configs don't exist. It is caused by uncaught exceptions during file reading, leading to EOSManager.Init ceasing to complete. This fix catches those exceptions and continues the init using default log levels
1 parent d3955b2 commit 74e64b0

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

com.playeveryware.eos/Runtime/Core/EOSManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,12 @@ private void InitializeLogLevels()
752752
{
753753
var logLevelList = LogLevelUtility.LogLevelList;
754754

755+
if (logLevelList == null)
756+
{
757+
SetLogLevel(LogCategory.AllCategories, LogLevel.Info);
758+
return;
759+
760+
}
755761
for (int logCategoryIndex = 0; logCategoryIndex < logLevelList.Count; logCategoryIndex++)
756762
{
757763
SetLogLevel((LogCategory)logCategoryIndex, logLevelList[logCategoryIndex]);

com.playeveryware.eos/Runtime/Core/Utility/LogLevelUtility.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,22 @@ public static List<LogLevel> LogLevelList
4343
{
4444
get
4545
{
46-
LogLevelConfig logLevelConfig = Config.Get<LogLevelConfig>();
46+
LogLevelConfig logLevelConfig = null;
47+
try
48+
{
49+
logLevelConfig = Config.Get<LogLevelConfig>();
50+
}
51+
catch (System.IO.FileNotFoundException)
52+
{
53+
Debug.Log($"Log level config does not exist, using default");
54+
return null;
55+
}
56+
catch (Exception exception)
57+
{
58+
Debug.LogWarning($"{exception}");
59+
Debug.Log($"Exception when reading log level config, using default");
60+
return null;
61+
}
4762

4863
List<LogLevel> logLevels = new List<LogLevel>();
4964
for (int i = 0; i < LogCategoryStringArray.Length - 1; i++)

0 commit comments

Comments
 (0)