Skip to content

Instantly share code, notes, and snippets.

@pacodelacruz
Created February 11, 2021 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacodelacruz/cc2af1b15bdd894d3c4418e5831eaf99 to your computer and use it in GitHub Desktop.
Save pacodelacruz/cc2af1b15bdd894d3c4418e5831eaf99 to your computer and use it in GitHub Desktop.
using Integration.Observability.Constants;
using Microsoft.Extensions.Logging;
namespace Integration.Observability.Helpers
{
public static class LoggerHelper
{
/// <summary>
/// Calculate LogLevel based on the process status.
/// </summary>
/// <param name="status"></param>
/// <returns>LogLevel</returns>
public static LogLevel CalculateLogLevel(LoggingConstants.Status status)
{
switch (status)
{
case LoggingConstants.Status.Succeeded:
return LogLevel.Information;
// When an attempt failed, but a retry is expected, return Warning
case LoggingConstants.Status.AttemptFailed:
// When a message is discarded due to business rules, return Warning
case LoggingConstants.Status.Discarded:
return LogLevel.Warning;
case LoggingConstants.Status.Failed:
return LogLevel.Error;
default:
return LogLevel.Information;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment