/// <summary>
 /// Logs the specified message.
 /// </summary>
 /// <param name="message">The message to log.</param>
 /// <param name="category">The (optional) category to attach to the message.</param>
 /// <param name="level">The <see cref="AmbientLogLevel"/> for the message.</param>
 public void Log(string message, string?category = null, AmbientLogLevel level = AmbientLogLevel.Information)
 {
     if (_logger == null)
     {
         return;
     }
     InnerLog(message, category, level);
 }
 /// <summary>
 /// Logs the message returned by the delegate.
 /// </summary>
 /// <param name="messageLambda">A delegate that creates a message.</param>
 /// <param name="category">The (optional) category to attach to the message.</param>
 /// <param name="level">The <see cref="AmbientLogLevel"/> for the message.</param>
 public void Log(Func <string> messageLambda, string?category = null, AmbientLogLevel level = AmbientLogLevel.Information)
 {
     if (_logger == null)
     {
         return;
     }
     if (messageLambda == null)
     {
         throw new ArgumentNullException(nameof(messageLambda));
     }
     InnerLog(messageLambda(), category, level);
 }
 internal void InnerLog(string message, string?category = null, AmbientLogLevel level = AmbientLogLevel.Information)
 {
     if (!_logFilter.IsBlocked(level, _typeName, category))
     {
         if (!string.IsNullOrEmpty(category))
         {
             category = category + ":";
         }
         message = String.Format(System.Globalization.CultureInfo.InvariantCulture, _MessageFormatString.Value, DateTime.UtcNow, level, _typeName, category, message);
         _logger !.Log(message);  // the calling of this method is short-circuited when _logger is null
     }
 }
 /// <summary>
 /// Logs the specified message and exception.
 /// </summary>
 /// <param name="message">The message to log.</param>
 /// <param name="ex">An <see cref="Exception"/> to log.  The exception will be appended after the message.</param>
 /// <param name="category">The (optional) category to attach to the message.</param>
 /// <param name="level">The <see cref="AmbientLogLevel"/> for the message.</param>
 public void Log(string message, Exception ex, string?category = null, AmbientLogLevel level = AmbientLogLevel.Error)
 {
     if (_logger == null)
     {
         return;
     }
     if (ex == null)
     {
         throw new ArgumentNullException(nameof(ex));
     }
     InnerLog(message + Environment.NewLine + ex.ToString(), category, level);
 }
 internal bool IsBlocked(AmbientLogLevel level, string typeName, string?categoryName)
 {
     if (level > _logLevelSetting.Value)
     {
         return(true);
     }
     if (IsTypeBlocked(typeName))
     {
         return(true);
     }
     if (IsCategoryBlocked(categoryName))
     {
         return(true);
     }
     return(false);
 }