<commit_before>﻿using System;
using Serilog.Events;

namespace Serilog
{
    /// <summary>
    /// Extension method 'ForContext' for ILogger.
    /// </summary>
    public static class ForContextExtension
    {
        /// <summary>
        /// Create a logger that enriches log events with the specified property based on log event level.
        /// </summary>
        /// <typeparam name="TValue"> The type of the property value. </typeparam>
        /// <param name="logger">The logger</param>
        /// <param name="level">The log event level used to determine if log is enriched with property.</param>
        /// <param name="propertyName">The name of the property. Must be non-empty.</param>
        /// <param name="value">The property value.</param>
        /// <param name="destructureObjects">If true, the value will be serialized as a structured
        /// object if possible; if false, the object will be recorded as a scalar or simple array.</param>
        /// <returns>A logger that will enrich log events as specified.</returns>
        /// <returns></returns>
        public static ILogger ForContext<TValue>(
            this ILogger logger,
            LogEventLevel level,
            string propertyName,
            TValue value,
            bool destructureObjects = false)
        {
            if (logger == null)
                throw new ArgumentNullException(nameof(logger));

            return !logger.IsEnabled(level)
                ? logger
                : logger.ForContext(propertyName, value, destructureObjects);
        }
    }
}<commit_msg>Simplify ternary operation (not !)<commit_after>﻿using System;
using Serilog.Events;

namespace Serilog
{
    /// <summary>
    /// Extension method 'ForContext' for ILogger.
    /// </summary>
    public static class ForContextExtension
    {
        /// <summary>
        /// Create a logger that enriches log events with the specified property based on log event level.
        /// </summary>
        /// <typeparam name="TValue"> The type of the property value. </typeparam>
        /// <param name="logger">The logger</param>
        /// <param name="level">The log event level used to determine if log is enriched with property.</param>
        /// <param name="propertyName">The name of the property. Must be non-empty.</param>
        /// <param name="value">The property value.</param>
        /// <param name="destructureObjects">If true, the value will be serialized as a structured
        /// object if possible; if false, the object will be recorded as a scalar or simple array.</param>
        /// <returns>A logger that will enrich log events as specified.</returns>
        /// <returns></returns>
        public static ILogger ForContext<TValue>(
            this ILogger logger,
            LogEventLevel level,
            string propertyName,
            TValue value,
            bool destructureObjects = false)
        {
            if (logger == null)
                throw new ArgumentNullException(nameof(logger));

            return logger.IsEnabled(level)
                ? logger.ForContext(propertyName, value, destructureObjects)
                : logger;
        }
    }
}
{'fraction_non_alphanumeric': 0.10776942355889724, 'fraction_numerical': 0.0, 'mean_word_length': 2.121212121212121, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3505833', 'n_tokens_mistral': 789, 'n_tokens_neox': 773, 'n_words': 282}