Created
February 11, 2021 00:54
-
-
Save pacodelacruz/cc2af1b15bdd894d3c4418e5831eaf99 to your computer and use it in GitHub Desktop.
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
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