From 5f5ef355cdb804f8d2ddfd8e2b414c991d0644c5 Mon Sep 17 00:00:00 2001 From: kaqq <58994315+kaqq@users.noreply.github.com> Date: Tue, 31 Dec 2019 13:46:02 +0100 Subject: [PATCH] setttings log level mapping --- src/Logbert/Logging/LogMessageLog4Net.cs | 35 ++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Logbert/Logging/LogMessageLog4Net.cs b/src/Logbert/Logging/LogMessageLog4Net.cs index 9d2d985..21cc225 100644 --- a/src/Logbert/Logging/LogMessageLog4Net.cs +++ b/src/Logbert/Logging/LogMessageLog4Net.cs @@ -325,22 +325,29 @@ private bool ParseData(string data) /// The mapped . private LogLevel MapLevelType(string levelType) { - if (!string.IsNullOrEmpty(levelType)) + if (!string.IsNullOrEmpty(levelType)) { - switch (levelType.ToUpper()) + var level = levelType; + if (Settings.Default.LevelTRACE.Split(';').Any(x=>String.Equals(x,level,StringComparison.CurrentCultureIgnoreCase))) { - case "TRACE": - return LogLevel.Trace; - case "DEBUG": - return LogLevel.Debug; - case "INFO": - return LogLevel.Info; - case "WARN": - return LogLevel.Warning; - case "ERROR": - return LogLevel.Error; - case "FATAL": - return LogLevel.Fatal; + return LogLevel.Trace; + } + else if (Settings.Default.LevelDEBUG.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase))) + + { + return LogLevel.Debug; + } + else if (Settings.Default.LevelINFO.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase))) + { + return LogLevel.Info; + } + else if (Settings.Default.LevelWARN.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase))) + { + return LogLevel.Warning; + } + else if (Settings.Default.LevelFATAL.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase))) + { + return LogLevel.Fatal; } }