mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-12 13:36:26 +01:00
35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
using System;
|
|
using Serilog;
|
|
using TINK.Repository.Exception;
|
|
|
|
namespace TINK.Model.Logging
|
|
{
|
|
public static class LogEntryClassifyHelper
|
|
{
|
|
/// <summary> Classifies exception and logs information or error depending on result of classification. </summary>
|
|
/// <typeparam name="T0">Type of first message parameter.</typeparam>
|
|
/// <typeparam name="T1">Type of second message parameter.</typeparam>
|
|
/// <param name="p_oLogger">Object to use for logging.</param>
|
|
/// <param name="messageTemplate">Templated used to output message.</param>
|
|
/// <param name="propertyValue0">First message parameter.</param>
|
|
/// <param name="propertyValue1">Second message parameter.</param>
|
|
/// <param name="p_oException">Exception to classify.</param>
|
|
public static void InformationOrError<T0, T1>(this ILogger p_oLogger, string messageTemplate, T0 propertyValue0, T1 propertyValue1, Exception p_oException)
|
|
{
|
|
if (p_oException == null)
|
|
{
|
|
p_oLogger.Error(messageTemplate, propertyValue0, propertyValue1, string.Empty);
|
|
return;
|
|
}
|
|
|
|
if (p_oException.GetIsConnectFailureException())
|
|
{
|
|
// Expected exception (LAN or mobile data off/ not reachable, proxy, ...)
|
|
p_oLogger.Information(messageTemplate, propertyValue0, propertyValue1, p_oException);
|
|
return;
|
|
}
|
|
|
|
p_oLogger.Error(messageTemplate, propertyValue0, propertyValue1, p_oException);
|
|
}
|
|
}
|
|
}
|