-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
89011d6
commit 4f57fd2
Showing
11 changed files
with
192 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/NLog.Targets.Syslog/MessageCreation/LogLevelSeverityMapping.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed under the BSD license | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System.Collections.Generic; | ||
using NLog.Targets.Syslog.Settings; | ||
|
||
namespace NLog.Targets.Syslog.MessageCreation | ||
{ | ||
internal class LogLevelSeverityMapping | ||
{ | ||
private readonly IDictionary<LogLevel, Severity> logLevelSeverityMapping; | ||
|
||
public LogLevelSeverityMapping(LogLevelSeverityConfig logLevelSeverityConfig) | ||
{ | ||
logLevelSeverityMapping = new Dictionary<LogLevel, Severity> | ||
{ | ||
{ LogLevel.Fatal, logLevelSeverityConfig.Fatal }, | ||
{ LogLevel.Error, logLevelSeverityConfig.Error }, | ||
{ LogLevel.Warn, logLevelSeverityConfig.Warn }, | ||
{ LogLevel.Info, logLevelSeverityConfig.Info }, | ||
{ LogLevel.Debug, logLevelSeverityConfig.Debug }, | ||
{ LogLevel.Trace, logLevelSeverityConfig.Trace } | ||
}; | ||
} | ||
|
||
public Severity this[LogLevel logLevel] => logLevelSeverityMapping[logLevel]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
src/NLog.Targets.Syslog/Settings/LogLevelSeverityConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Licensed under the BSD license | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
using System.ComponentModel; | ||
|
||
namespace NLog.Targets.Syslog.Settings | ||
{ | ||
/// <inheritdoc cref="NotifyPropertyChanged" /> | ||
/// <summary>Log level to severity configuration</summary> | ||
public class LogLevelSeverityConfig : NotifyPropertyChanged | ||
{ | ||
private Severity fatal; | ||
private Severity error; | ||
private Severity warn; | ||
private Severity info; | ||
private Severity debug; | ||
private Severity trace; | ||
|
||
/// <summary>The Syslog severity for log level fatal</summary> | ||
public Severity Fatal | ||
{ | ||
get => fatal; | ||
set => SetProperty(ref fatal, value); | ||
} | ||
|
||
/// <summary>The Syslog severity for log level error</summary> | ||
public Severity Error | ||
{ | ||
get => error; | ||
set => SetProperty(ref error, value); | ||
} | ||
|
||
/// <summary>The Syslog severity for log level warn</summary> | ||
public Severity Warn | ||
{ | ||
get => warn; | ||
set => SetProperty(ref warn, value); | ||
} | ||
|
||
/// <summary>The Syslog severity for log level info</summary> | ||
public Severity Info | ||
{ | ||
get => info; | ||
set => SetProperty(ref info, value); | ||
} | ||
|
||
/// <summary>The Syslog severity for log level debug</summary> | ||
public Severity Debug | ||
{ | ||
get => debug; | ||
set => SetProperty(ref debug, value); | ||
} | ||
|
||
/// <summary>The Syslog severity for log level trace</summary> | ||
public Severity Trace | ||
{ | ||
get => trace; | ||
set => SetProperty(ref trace, value); | ||
} | ||
|
||
/// <summary>Builds a new instance of the LogLevelSeverityConfig class</summary> | ||
public LogLevelSeverityConfig() | ||
{ | ||
fatal = Severity.Emergency; | ||
error = Severity.Error; | ||
warn = Severity.Warning; | ||
info = Severity.Informational; | ||
debug = Severity.Debug; | ||
trace = Severity.Notice; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed under the BSD license | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace NLog.Targets.Syslog.Settings | ||
{ | ||
/// <summary>Syslog severities</summary> | ||
public enum Severity | ||
{ | ||
/// <summary>Emergency severity</summary> | ||
Emergency = 0, | ||
|
||
/// <summary>Alert severity</summary> | ||
Alert = 1, | ||
|
||
/// <summary>Critical severity</summary> | ||
Critical = 2, | ||
|
||
/// <summary>Error severity</summary> | ||
Error = 3, | ||
|
||
/// <summary>Warning severity</summary> | ||
Warning = 4, | ||
|
||
/// <summary>Notice severity</summary> | ||
Notice = 5, | ||
|
||
/// <summary>Informational severity</summary> | ||
Informational = 6, | ||
|
||
/// <summary>Debug severity</summary> | ||
Debug = 7 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters