private void UpdateByActiveChange(bool oldIsActive, bool newIsActive) { if (oldIsActive == newIsActive) { return; } if (newIsActive) { var levels = GetLogsByLevel(SelectedMinLogLevel); levels.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.AddOrdered(m); } }); } else { LogsTrace.ForEach((m) => { Logs.Remove(m); }); LogsDebug.ForEach((m) => { Logs.Remove(m); }); LogsInfo.ForEach((m) => { Logs.Remove(m); }); LogsWarn.ForEach((m) => { Logs.Remove(m); }); LogsError.ForEach((m) => { Logs.Remove(m); }); LogsFatal.ForEach((m) => { Logs.Remove(m); }); } }
private void UpdateByLogLevelChange(LoggingLevel oldLogLevel, LoggingLevel newLogLevel) { if (!IsActive) { return; } if (oldLogLevel == null || newLogLevel == null || oldLogLevel.Id == newLogLevel.Id) { return; } bool isAdd = oldLogLevel.Id > newLogLevel.Id; var levelsBetween = LoggingLevel.GetLogLevelsBetween(oldLogLevel, newLogLevel); foreach (var levelBetween in levelsBetween) { if (levelBetween == LoggingLevel.TRACE) { if (isAdd) { LogsTrace.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.AddOrdered(m); } }); } else { LogsTrace.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.Remove(m); } }); } } else if (levelBetween == LoggingLevel.DEBUG) { if (isAdd) { LogsDebug.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.AddOrdered(m); } }); } else { LogsDebug.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.Remove(m); } }); } } else if (levelBetween == LoggingLevel.INFO) { if (isAdd) { LogsInfo.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.AddOrdered(m); } }); } else { LogsInfo.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.Remove(m); } }); } } else if (levelBetween == LoggingLevel.WARN) { if (isAdd) { LogsWarn.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.AddOrdered(m); } }); } else { LogsWarn.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.Remove(m); } }); } } else if (levelBetween == LoggingLevel.ERROR) { if (isAdd) { LogsError.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.AddOrdered(m); } }); } else { LogsError.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.Remove(m); } }); } } else if (levelBetween == LoggingLevel.FATAL) { if (isAdd) { LogsFatal.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.AddOrdered(m); } }); } else { LogsFatal.ForEach((m) => { if (IsNamespaceActive(m) && IsSearchCriteriaMatch(m)) { Logs.Remove(m); } }); } } } }