diff --git a/src/Logging/CoscineLogger.cs b/src/Logging/CoscineLogger.cs index 88a714ac947d6d864525c389d9219369ca91758c..bb7497f7b346e484bd6a928f6139d7ea5c9d7bbe 100644 --- a/src/Logging/CoscineLogger.cs +++ b/src/Logging/CoscineLogger.cs @@ -350,13 +350,13 @@ namespace Coscine.Logging private static void UpdateActiveLogs() { - activeLoglevels[(int)LogType.Debug] = !GetStringFromConsul(LogLevelKeyDebug).Equals("0"); - activeLoglevels[(int)LogType.Low] = !GetStringFromConsul(LogLevelKeyLow).Equals("0"); - activeLoglevels[(int)LogType.Medium] = !GetStringFromConsul(LogLevelKeyMedium).Equals("0"); - activeLoglevels[(int)LogType.High] = !GetStringFromConsul(LogLevelKeyHigh).Equals("0"); - activeLoglevels[(int)LogType.Critical] = !GetStringFromConsul(LogLevelKeyCritical).Equals("0"); - activeLoglevels[(int)LogType.Analytics] = !GetStringFromConsul(LogLevelKeyAnalytics).Equals("0"); - activeLoglevels[(int)LogType.Reporting] = !GetStringFromConsul(LogLevelKeyReporting).Equals("0"); + activeLoglevels[(int)LogType.Debug] = !GetStringFromConsul(LogLevelKeyDebug, "0").Equals("0"); + activeLoglevels[(int)LogType.Low] = !GetStringFromConsul(LogLevelKeyLow, "0").Equals("0"); + activeLoglevels[(int)LogType.Medium] = !GetStringFromConsul(LogLevelKeyMedium, "0").Equals("0"); + activeLoglevels[(int)LogType.High] = !GetStringFromConsul(LogLevelKeyHigh, "1").Equals("0"); + activeLoglevels[(int)LogType.Critical] = !GetStringFromConsul(LogLevelKeyCritical, "1").Equals("0"); + activeLoglevels[(int)LogType.Analytics] = !GetStringFromConsul(LogLevelKeyAnalytics, "0").Equals("0"); + activeLoglevels[(int)LogType.Reporting] = !GetStringFromConsul(LogLevelKeyReporting, "0").Equals("0"); var config = LogManager.Configuration; config.FindRuleByName("blockAllInformation").Final = !activeLoglevels[(int)LogType.Analytics] && !activeLoglevels[(int)LogType.Reporting]; @@ -392,15 +392,28 @@ namespace Coscine.Logging getPair.Wait(); - var returnValue = getPair.Result.Response.Value; - - if (returnValue != null) + if (getPair.Result.Response?.Value != null) + { + var value = getPair.Result.Response.Value; + return Encoding.UTF8.GetString(value, 0, value.Length); + } + else { - return Encoding.UTF8.GetString(returnValue, 0, returnValue.Length); + // TODO: Add logging that key has not been found + return null; } - return null; + } + } + private static string GetStringFromConsul(string key, string defaultValue) + { + var value = GetStringFromConsul(key); + if(value == null) + { + // TODO: Add logging that default value has been used + return defaultValue; } + return value; } } }