コード例 #1
0
        private static void Act(IContribFullLogger logger, LogLevel thresholdLogLevel, [NotNull] Func <string> valueFunction, [NotNull] Action <string, Exception> logAction, [NotNull] Exception ex, IDictionary <string, string> contextPropertyCollection)
        {
            if (logger.Level <= thresholdLogLevel)
            {
                if (contextPropertyCollection != null && contextPropertyCollection.Count > 0)
                {
                    logger.SetContextProperties(contextPropertyCollection);
                }

                logAction.Invoke(valueFunction.Invoke(), ex);
            }
        }
コード例 #2
0
        private static void Act(IContribFullLogger logger, LogLevel thresholdLogLevel, [NotNull]Func<string> valueFunction, [NotNull]Action<string, Exception> logAction, [NotNull]Exception ex, IDictionary<string, string> contextPropertyCollection)
        {
            if (logger.Level <= thresholdLogLevel)
            {
                if (contextPropertyCollection != null && contextPropertyCollection.Count > 0)
                {
                    logger.SetContextProperties(contextPropertyCollection);
                }

                logAction.Invoke(valueFunction.Invoke(), ex);
            }
        }
コード例 #3
0
 /// <summary>
 /// Checks if the Warn log level is enabled then evaluates the string function and logs the message along with the exception.
 /// </summary>
 /// <param name="logger">The splat logger.</param>
 /// <param name="valueFunction">The string function to evaluate if the log level is enabled</param>
 /// <param name="exception">The exception that occurred</param>
 /// <param name="contextPropertyCollection">Collection of Key\Value pairs to attach as properties to the logging context</param>
 public static void WarnException(this IContribFullLogger logger, [NotNull] Func <string> valueFunction, [NotNull] Exception exception, IDictionary <string, string> contextPropertyCollection)
 {
     Act(logger, LogLevel.Warn, valueFunction, logger.Warn, exception, contextPropertyCollection);
 }
コード例 #4
0
 /// <summary>
 /// Checks if the Info log level is enabled then evaluates the string function and logs the message.
 /// </summary>
 /// <param name="logger">The splat logger.</param>
 /// <param name="valueFunction">The string function to evaluate if the log level is enabled</param>
 /// <param name="contextPropertyCollection">Collection of Key\Value pairs to attach as properties to the logging context</param>
 public static void Info(this IContribFullLogger logger, [NotNull] Func <string> valueFunction, IDictionary <string, string> contextPropertyCollection)
 {
     Act(logger, LogLevel.Info, valueFunction, logger.Info, contextPropertyCollection);
 }