Add project files.
This commit is contained in:
43
Core.Blueprint.Logging/Adapters/ErrorDetails.cs
Normal file
43
Core.Blueprint.Logging/Adapters/ErrorDetails.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="ErrorDetailsDto.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The service error details transfer object.
|
||||
/// </summary>
|
||||
public class ErrorDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the service error code.
|
||||
/// </summary>
|
||||
/// <example>healthy</example>
|
||||
[DisplayName(DisplayNames.ErrorCode)]
|
||||
[JsonPropertyName(DisplayNames.ErrorCode)]
|
||||
public string? ErrorCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the service error message.
|
||||
/// </summary>
|
||||
/// <example>This is an example message.</example>
|
||||
[DisplayName(DisplayNames.Message)]
|
||||
[JsonPropertyName(DisplayNames.Message)]
|
||||
public string? Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the service target.
|
||||
/// </summary>
|
||||
/// <example>healthy</example>
|
||||
[DisplayName(DisplayNames.Target)]
|
||||
[JsonPropertyName(DisplayNames.Target)]
|
||||
public string? Target { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
45
Core.Blueprint.Logging/Adapters/HttpError.cs
Normal file
45
Core.Blueprint.Logging/Adapters/HttpError.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="HttpErrorDto.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The service HTTP error data transfer object.
|
||||
/// </summary>
|
||||
public class HttpError
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error.
|
||||
/// </summary>
|
||||
[DisplayName(DisplayNames.Error)]
|
||||
[JsonPropertyName(DisplayNames.Error)]
|
||||
public ErrorDetails Error { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="HttpError{TMessage}"/>
|
||||
/// with custom parameters.
|
||||
/// </summary>
|
||||
/// <param name="message">The HTTP error message.</param>
|
||||
/// <param name="errorCode">The HTTP error code.</param>
|
||||
/// <param name="target">The HTTP error target.</param>
|
||||
public HttpError(
|
||||
string? message,
|
||||
string? errorCode,
|
||||
string? target)
|
||||
{
|
||||
Error = new ErrorDetails
|
||||
{
|
||||
ErrorCode = errorCode,
|
||||
Message = message,
|
||||
Target = target,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
Core.Blueprint.Logging/Adapters/HttpException.cs
Normal file
41
Core.Blueprint.Logging/Adapters/HttpException.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="HttpException.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The service HTTP exception.
|
||||
/// Extends the <see cref="Exception"/> class.
|
||||
/// </summary>
|
||||
public class HttpException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the exception error code.
|
||||
/// </summary>
|
||||
public string? ErrorCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exception status code.
|
||||
/// </summary>
|
||||
public int StatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="HttpException"/>.
|
||||
/// </summary>
|
||||
/// <param name="statusCode">The exception status code.</param>
|
||||
/// <param name="errorCode">The exception error code.</param>
|
||||
/// <param name="message">The exception message.</param>
|
||||
public HttpException(
|
||||
int statusCode,
|
||||
string errorCode,
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
ErrorCode = errorCode;
|
||||
StatusCode = statusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Core.Blueprint.Logging/Adapters/LogDetail.cs
Normal file
120
Core.Blueprint.Logging/Adapters/LogDetail.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="LogDetail.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The service logger detail object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TMessage">The generic message type.</typeparam>
|
||||
public class LogDetail<TMessage>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the log severity.
|
||||
/// </summary>
|
||||
/// <example>info</example>
|
||||
[DisplayName(DisplayNames.Severity)]
|
||||
[JsonPropertyName(DisplayNames.Severity)]
|
||||
public LogSeverity Severity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timestamp.
|
||||
/// </summary>
|
||||
[DisplayName(DisplayNames.Timestamp)]
|
||||
[JsonPropertyName(DisplayNames.Timestamp)]
|
||||
public DateTime Timestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the environment.
|
||||
/// </summary>
|
||||
/// <example>Development</example>
|
||||
[DisplayName(DisplayNames.Environment)]
|
||||
[JsonPropertyName(DisplayNames.Environment)]
|
||||
public string? Environment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the target.
|
||||
/// </summary>
|
||||
[DisplayName(DisplayNames.Target)]
|
||||
[JsonPropertyName(DisplayNames.Target)]
|
||||
public LogTarget? Target { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the x-forwarded-for header.
|
||||
/// </summary>
|
||||
/// <example>localhost</example>
|
||||
[DisplayName(DisplayNames.XForwardedFor)]
|
||||
[JsonPropertyName(DisplayNames.XForwardedFor)]
|
||||
public string? XForwardedFor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the service identifier.
|
||||
/// </summary>
|
||||
/// <example><see cref="Guid.NewGuid()"/></example>
|
||||
[DisplayName(DisplayNames.ServiceId)]
|
||||
[JsonPropertyName(DisplayNames.ServiceId)]
|
||||
public string? ServiceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the request identifier.
|
||||
/// </summary>
|
||||
/// <example><see cref="Guid.NewGuid()"/></example>
|
||||
[DisplayName(DisplayNames.RequestId)]
|
||||
[JsonPropertyName(DisplayNames.RequestId)]
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the keyVaultProvider identifier.
|
||||
/// </summary>
|
||||
/// <example><see cref="Guid.NewGuid()"/></example>
|
||||
[DisplayName(DisplayNames.ClientId)]
|
||||
[JsonPropertyName(DisplayNames.ClientId)]
|
||||
public string? ClientId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the keyVaultProvider identifier.
|
||||
/// </summary>
|
||||
/// <example>keyVaultProviderRequest</example>
|
||||
[DisplayName(DisplayNames.Operation)]
|
||||
[JsonPropertyName(DisplayNames.Operation)]
|
||||
public LogOperation Operation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user name.
|
||||
/// </summary>
|
||||
/// <example>keyVaultProviderRequest</example>
|
||||
[DisplayName(DisplayNames.User)]
|
||||
[JsonPropertyName(DisplayNames.User)]
|
||||
public string? User { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets user's email.
|
||||
/// </summary>
|
||||
/// <example>keyVaultProviderRequest</example>
|
||||
[DisplayName(DisplayNames.Email)]
|
||||
[JsonPropertyName(DisplayNames.Email)]
|
||||
public string? Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user identifier.
|
||||
/// </summary>
|
||||
/// <example>keyVaultProviderRequest</example>
|
||||
[DisplayName(DisplayNames.UserId)]
|
||||
[JsonPropertyName(DisplayNames.UserId)]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the message.
|
||||
/// </summary>
|
||||
/// <example>A custom log message.</example>
|
||||
[DisplayName(DisplayNames.Message)]
|
||||
[JsonPropertyName(DisplayNames.Message)]
|
||||
public TMessage? Message { get; set; }
|
||||
}
|
||||
}
|
||||
55
Core.Blueprint.Logging/Adapters/LogOperation.cs
Normal file
55
Core.Blueprint.Logging/Adapters/LogOperation.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="LogOperation.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents all possible values for log operation.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public enum LogOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The keyVaultProvider request log operation type.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.ClientRequest)]
|
||||
[JsonPropertyName(DisplayNames.ClientRequest)]
|
||||
ClientRequest = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The keyVaultProvider response log operation type.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.ClientResponse)]
|
||||
ClientResponse = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The external request log operation type.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.ExternalRequest)]
|
||||
ExternalRequest = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The external response log operation type.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.ExternalResponse)]
|
||||
ExternalResponse = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The error log operation type.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.Error)]
|
||||
Error = 4,
|
||||
|
||||
/// <summary>
|
||||
/// The info log operation type.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.Info)]
|
||||
Info = 5,
|
||||
}
|
||||
}
|
||||
41
Core.Blueprint.Logging/Adapters/LogSeverity.cs
Normal file
41
Core.Blueprint.Logging/Adapters/LogSeverity.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="LogSeverity.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents all possible values for log severity.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public enum LogSeverity
|
||||
{
|
||||
/// <summary>
|
||||
/// The information severity level.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.Information)]
|
||||
Info = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The warning severity level.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.Warning)]
|
||||
Warn = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The error severity level.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.Error)]
|
||||
Error = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The fatal severity level.
|
||||
/// </summary>
|
||||
[EnumMember(Value = DisplayNames.Fatal)]
|
||||
Fatal = 3,
|
||||
}
|
||||
}
|
||||
41
Core.Blueprint.Logging/Adapters/LogTarget.cs
Normal file
41
Core.Blueprint.Logging/Adapters/LogTarget.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="LogTarget.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The service logger target object.
|
||||
/// </summary>
|
||||
public class LogTarget
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the log target method.
|
||||
/// </summary>
|
||||
/// <example>GET</example>
|
||||
[DisplayName(DisplayNames.Method)]
|
||||
[JsonPropertyName(DisplayNames.Method)]
|
||||
public string? Method { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the log target host.
|
||||
/// </summary>
|
||||
/// <example>GET</example>
|
||||
[DisplayName(DisplayNames.Host)]
|
||||
[JsonPropertyName(DisplayNames.Host)]
|
||||
public string? Host { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the log target route.
|
||||
/// </summary>
|
||||
/// <example>GET</example>
|
||||
[DisplayName(DisplayNames.Route)]
|
||||
[JsonPropertyName(DisplayNames.Route)]
|
||||
public string? Route { get; set; }
|
||||
}
|
||||
}
|
||||
20
Core.Blueprint.Logging/Adapters/ServiceSettings.cs
Normal file
20
Core.Blueprint.Logging/Adapters/ServiceSettings.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="ServiceSettings.cs">
|
||||
// Heath
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
namespace Core.Blueprint.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The service settings.
|
||||
/// </summary>
|
||||
public class ServiceSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the service identifier.
|
||||
/// </summary>
|
||||
public string? ApplicationName { get; set; }
|
||||
public string? LayerName { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user