-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds data parameter. Adds Multilogger. Updates packages.
- Loading branch information
Showing
19 changed files
with
262 additions
and
29 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
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
12 changes: 12 additions & 0 deletions
12
Source/Vima.LoggingAbstractor.AppInsights/IAppInsightsLogger.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,12 @@ | ||
using Vima.LoggingAbstractor.Core; | ||
|
||
namespace Vima.LoggingAbstractor.AppInsights | ||
{ | ||
/// <summary> | ||
/// Represents an instance of an Application Insights logger. | ||
/// </summary> | ||
/// <seealso cref="Vima.LoggingAbstractor.Core.ILogger" /> | ||
public interface IAppInsightsLogger : ILogger | ||
{ | ||
} | ||
} |
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 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,9 @@ | ||
namespace Vima.LoggingAbstractor.Core | ||
{ | ||
/// <summary> | ||
/// Responsible for combining multiple loggers at the same time. | ||
/// </summary> | ||
public interface IMultiLogger : ILogger | ||
{ | ||
} | ||
} |
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,92 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Vima.LoggingAbstractor.Core.Parameters; | ||
|
||
namespace Vima.LoggingAbstractor.Core | ||
{ | ||
/// <summary> | ||
/// Responsible for combining multiple loggers at the same time. | ||
/// </summary> | ||
public class MultiLogger : IMultiLogger | ||
{ | ||
private readonly IEnumerable<ILogger> _loggers; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MultiLogger"/> class. | ||
/// </summary> | ||
/// <param name="loggers">The loggers used to trace events.</param> | ||
protected MultiLogger(IEnumerable<ILogger> loggers) | ||
{ | ||
_loggers = loggers ?? throw new ArgumentNullException(nameof(loggers)); | ||
} | ||
|
||
/// <summary> | ||
/// Traces the message. | ||
/// </summary> | ||
/// <param name="message">The message to be logged.</param> | ||
public void TraceMessage(string message) | ||
{ | ||
TraceMessage(message, LoggingLevel.Verbose); | ||
} | ||
|
||
/// <summary> | ||
/// Traces the message. | ||
/// </summary> | ||
/// <param name="message">The message to be logged.</param> | ||
/// <param name="loggingLevel">The logging level.</param> | ||
public void TraceMessage(string message, LoggingLevel loggingLevel) | ||
{ | ||
TraceMessage(message, loggingLevel, Enumerable.Empty<ILoggingParameter>()); | ||
} | ||
|
||
/// <summary> | ||
/// Traces the message. | ||
/// </summary> | ||
/// <param name="message">The message to be logged.</param> | ||
/// <param name="loggingLevel">The logging level.</param> | ||
/// <param name="parameters">The logging parameters.</param> | ||
public void TraceMessage(string message, LoggingLevel loggingLevel, IEnumerable<ILoggingParameter> parameters) | ||
{ | ||
IEnumerable<ILoggingParameter> loggingParameters = parameters.ToList(); | ||
foreach (var logger in _loggers) | ||
{ | ||
logger.TraceMessage(message, loggingLevel, loggingParameters); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Traces the exception. | ||
/// </summary> | ||
/// <param name="exception">The exception to be logged.</param> | ||
public void TraceException(Exception exception) | ||
{ | ||
TraceException(exception, LoggingLevel.Critical); | ||
} | ||
|
||
/// <summary> | ||
/// Traces the exception. | ||
/// </summary> | ||
/// <param name="exception">The exception to be logged.</param> | ||
/// <param name="loggingLevel">The logging level.</param> | ||
public void TraceException(Exception exception, LoggingLevel loggingLevel) | ||
{ | ||
TraceException(exception, loggingLevel, Enumerable.Empty<ILoggingParameter>()); | ||
} | ||
|
||
/// <summary> | ||
/// Traces the exception. | ||
/// </summary> | ||
/// <param name="exception">The exception to be logged.</param> | ||
/// <param name="loggingLevel">The logging level.</param> | ||
/// <param name="parameters">The logging parameters.</param> | ||
public void TraceException(Exception exception, LoggingLevel loggingLevel, IEnumerable<ILoggingParameter> parameters) | ||
{ | ||
IEnumerable<ILoggingParameter> loggingParameters = parameters.ToList(); | ||
foreach (var logger in _loggers) | ||
{ | ||
logger.TraceException(exception, loggingLevel, loggingParameters); | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Source/Vima.LoggingAbstractor.Core/Parameters/LoggingDataParameter.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,35 @@ | ||
using System; | ||
|
||
namespace Vima.LoggingAbstractor.Core.Parameters | ||
{ | ||
/// <summary> | ||
/// Represents logging data parameter. | ||
/// </summary> | ||
public class LoggingDataParameter : ILoggingParameter<object> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="LoggingDataParameter"/> class. | ||
/// </summary> | ||
/// <param name="data">The data.</param> | ||
public LoggingDataParameter(object data) | ||
{ | ||
Value = data ?? throw new ArgumentNullException(nameof(data)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the parameter's value. | ||
/// </summary> | ||
/// <value> | ||
/// The parameter's value. | ||
/// </value> | ||
public object Value { get; } | ||
|
||
/// <summary> | ||
/// Gets the type of the logging parameter. | ||
/// </summary> | ||
/// <value> | ||
/// The type of the logging parameter. | ||
/// </value> | ||
public LoggingParameterType LoggingParameterType => LoggingParameterType.Data; | ||
} | ||
} |
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 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,11 @@ | ||
using Vima.LoggingAbstractor.Core; | ||
|
||
namespace Vima.LoggingAbstractor.Raygun | ||
{ | ||
/// <summary> | ||
/// Represents an instance of a Raygun logger. | ||
/// </summary> | ||
public interface IRaygunLogger : ILogger | ||
{ | ||
} | ||
} |
Oops, something went wrong.