Exemplo n.º 1
0
 /// <summary>
 /// Safe logging of a message. Will check for errors, but never throw an exception. If the log can't be made, a fallback log will be created.
 /// </summary>
 /// <param name="logger">The logger to use for publishing the message.</param>
 /// <param name="severityLevel">The severity level for this log.</param>
 /// <param name="message">The message to log (will be concatenated with any <paramref name="exception"/> information).</param>
 /// <param name="exception">Optional exception</param>
 public static async Task LogAsync(IFulcrumLogger logger, LogSeverityLevel severityLevel, string message, Exception exception = null)
 {
     try
     {
         InternalContract.RequireNotNull(logger, nameof(logger));
         var formattedMessage = FormatMessage(message, exception);
         await logger.LogAsync(severityLevel, formattedMessage);
     }
     catch (Exception)
     {
         // TODO: Log somewhere
         //var formattedMessage = FormatMessage(message, e);
         //await SafeLogger.Instance.LogAsync(tenant, SeverityLevel.Critical, formattedMessage);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Safe logging of a message. Will check for errors, but never throw an exception. If the log can't be made, a fallback log will be created.
 /// </summary>
 /// <param name="logger">The logger to use for publishing the message.</param>
 /// <param name="tenant">Current tenant.</param>
 /// <param name="severityLevel">The severity level for this log.</param>
 /// <param name="message">The message to log (will be concatenated with any <paramref name="exception"/> information).</param>
 /// <param name="exception">Optional exception</param>
 public static void Log(IFulcrumLogger logger, ITenant tenant, LogSeverityLevel severityLevel, string message, Exception exception = null)
 {
     try
     {
         InternalContract.RequireNotNull(logger, nameof(logger));
         InternalContract.RequireNotNull(tenant, nameof(tenant));
         var formattedMessage = FormatMessage(message, exception);
         logger.Log(tenant, severityLevel, formattedMessage);
     }
     catch (Exception)
     {
         // TODO: Log somewhere
         //var formattedMessage = FormatMessage(message, e);
         //SafeLogger.Instance.Log(tenant, SeverityLevel.Critical, formattedMessage);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="correlationIdProvider">A value provider that knows how to get the correlation id from the execution context.</param>
 /// <param name="logHandler">A log handler that knows how to log exceptions</param>
 public ConvertExceptionToFulcrumResponse(ICorrelationIdValueProvider correlationIdProvider, IFulcrumLogger logHandler)
 {
     _correlationIdProvider = correlationIdProvider;
     _logHandler            = logHandler;
 }