/// <summary> /// Loads debugging configurations. /// </summary> public static void LoadDebuggingConfig() { Debug.Log("[INFO] ContractConfigurator.LoggingUtil: Loading DebuggingConfig node."); // Don't know why .GetConfigNode("CC_DEBUGGING") returns null, using .GetConfigNodes("CC_DEBUGGING") works fine. ConfigNode[] debuggingConfigs = GameDatabase.Instance.GetConfigNodes("CC_DEBUGGING"); if (debuggingConfigs.Length > 0) { try { // Fetch config ConfigNode debuggingConfig = debuggingConfigs[0]; // Set LogLevel if (debuggingConfig.HasValue("logLevel")) { LoggingUtil.logLevel = (LoggingUtil.LogLevel)Enum.Parse(typeof(LoggingUtil.LogLevel), debuggingConfig.GetValue("logLevel")); LoggingUtil.LogInfo(typeof(LoggingUtil), "Set LogLevel = " + LoggingUtil.logLevel); } // Fetch specific loglevels for given types foreach (ConfigNode levelExceptionNode in debuggingConfig.GetNodes("ADD_LOGLEVEL_EXCEPTION")) { if (levelExceptionNode.HasValue("type") && levelExceptionNode.HasValue("logLevel")) { // Fetch full type name - just search and find the matching one while // ignoring namespace string typeName = levelExceptionNode.GetValue("type"); Type type = null; foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { try { foreach (Type t in a.GetTypes()) { if (t.Name == typeName || t.Name.StartsWith(typeName + '`')) { type = t; break; } } } catch (Exception e) { Debug.LogWarning("[WARNING] Error loading types from assembly " + a.FullName + ": " + e.Message); } } if (type != null) { LoggingUtil.LogLevel logLevel = (LoggingUtil.LogLevel)Enum.Parse(typeof(LoggingUtil.LogLevel), levelExceptionNode.GetValue("logLevel")); LoggingUtil.AddSpecificLogLevel(type, logLevel); } else { Debug.LogWarning("[WARNING] ContractConfigurator.LoggingUtil: Couldn't find Type with name: '" + typeName + "'"); } } else { Debug.LogWarning("[WARNING] ContractConfigurator.LoggingUtil: Couldn't load specific LogLevel node, type or logLevel not given!"); } } LoggingUtil.LogInfo(typeof(LoggingUtil), "DebugingConfig loaded!"); } catch (Exception e) { LoggingUtil.ClearSpecificLogLevel(); LoggingUtil.logLevel = LoggingUtil.LogLevel.INFO; LoggingUtil.LogWarning(typeof(LoggingUtil), "Debugging Config failed to load! Message: '" + e.Message + "' Set LogLevel to INFO and cleaned specific LogLevels"); } } else { LoggingUtil.logLevel = LoggingUtil.LogLevel.INFO; LoggingUtil.LogWarning(typeof(LoggingUtil), "No debugging config found! LogLevel set to INFO"); } }