Skip to content

Commit 5f5ef35

Browse files
authored
setttings log level mapping
1 parent b506ac5 commit 5f5ef35

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/Logbert/Logging/LogMessageLog4Net.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,22 +325,29 @@ private bool ParseData(string data)
325325
/// <returns>The mapped <see cref="LogLevel"/>.</returns>
326326
private LogLevel MapLevelType(string levelType)
327327
{
328-
if (!string.IsNullOrEmpty(levelType))
328+
if (!string.IsNullOrEmpty(levelType))
329329
{
330-
switch (levelType.ToUpper())
330+
var level = levelType;
331+
if (Settings.Default.LevelTRACE.Split(';').Any(x=>String.Equals(x,level,StringComparison.CurrentCultureIgnoreCase)))
331332
{
332-
case "TRACE":
333-
return LogLevel.Trace;
334-
case "DEBUG":
335-
return LogLevel.Debug;
336-
case "INFO":
337-
return LogLevel.Info;
338-
case "WARN":
339-
return LogLevel.Warning;
340-
case "ERROR":
341-
return LogLevel.Error;
342-
case "FATAL":
343-
return LogLevel.Fatal;
333+
return LogLevel.Trace;
334+
}
335+
else if (Settings.Default.LevelDEBUG.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
336+
337+
{
338+
return LogLevel.Debug;
339+
}
340+
else if (Settings.Default.LevelINFO.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
341+
{
342+
return LogLevel.Info;
343+
}
344+
else if (Settings.Default.LevelWARN.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
345+
{
346+
return LogLevel.Warning;
347+
}
348+
else if (Settings.Default.LevelFATAL.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
349+
{
350+
return LogLevel.Fatal;
344351
}
345352
}
346353

0 commit comments

Comments
 (0)