<commit_before>﻿// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading;
using Serilog.Core;
using Serilog.Core.Pipeline;
using Serilog.Events;

namespace Serilog
{
    /// <summary>
    /// An optional static entry point for logging that can be easily referenced
    /// by different parts of an application. To configure the <see cref="Log"/>
    /// set the Logger static property to a logger instance.
    /// </summary>
    /// <example>
    /// Log.Logger = new LoggerConfiguration()
    ///     .WithConsoleSink()
    ///     .CreateLogger();
    ///
    /// var thing = "World";
    /// Log.Logger.Information("Hello, {Thing}!", thing);
    /// </example>
    /// <remarks>
    /// The methods on <see cref="Log"/> (and its dynamic sibling <see cref="ILogger"/>) are guaranteed
    /// never to throw exceptions. Methods on all other types may.
    /// </remarks>
    public static class Log
    {
        static ILogger _logger = new SilentLogger();

        /// <summary>
        /// The globally-shared logger.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        public static ILogger Logger
        {
            get { return _logger; }
            set
            {
                if (value == null) throw new ArgumentNullException(nameof(value));
                _logger = value;
            }
        }

        /// <summary>
        /// Resets <see cref="Logger"/> to the default and disposes the original if possible
        /// </summary>
        public static void CloseAndFlush()
        {
            ILogger logger = Interlocked.Exchange(ref _logger, new SilentLogger());

            (logger as IDisposable)?.Dispose();
        }

        /// <summary>
        /// Create a logger that enriches log events via the provided enrichers.
        /// </summary>
        /// <param name="enrichers">Enrichers that apply in the context.</param>
        /// <returns>A logger that will enrich log events as specified.</returns><commit_msg>Add the new ForContext() overload to Log.<commit_after>﻿// Copyright 2013-2015 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading;
using Serilog.Core;
using Serilog.Core.Pipeline;
using Serilog.Events;

namespace Serilog
{
    /// <summary>
    /// An optional static entry point for logging that can be easily referenced
    /// by different parts of an application. To configure the <see cref="Log"/>
    /// set the Logger static property to a logger instance.
    /// </summary>
    /// <example>
    /// Log.Logger = new LoggerConfiguration()
    ///     .WithConsoleSink()
    ///     .CreateLogger();
    ///
    /// var thing = "World";
    /// Log.Logger.Information("Hello, {Thing}!", thing);
    /// </example>
    /// <remarks>
    /// The methods on <see cref="Log"/> (and its dynamic sibling <see cref="ILogger"/>) are guaranteed
    /// never to throw exceptions. Methods on all other types may.
    /// </remarks>
    public static class Log
    {
        static ILogger _logger = new SilentLogger();

        /// <summary>
        /// The globally-shared logger.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        public static ILogger Logger
        {
            get { return _logger; }
            set
            {
                if (value == null) throw new ArgumentNullException(nameof(value));
                _logger = value;
            }
        }

        /// <summary>
        /// Resets <see cref="Logger"/> to the default and disposes the original if possible
        /// </summary>
        public static void CloseAndFlush()
        {
            ILogger logger = Interlocked.Exchange(ref _logger, new SilentLogger());

            (logger as IDisposable)?.Dispose();
        }

        /// <summary>
        /// Create a logger that enriches log events via the provided enrichers.
        /// </summary>
        /// <param name="enricher">Enricher that applies in the context.</param>
        /// <returns>A logger that will enrich log events as specified.</returns>
        public static ILogger ForContext(ILogEventEnricher enricher)
        {
            return Logger.ForContext(enricher);
        }

        /// <summary>
        /// Create a logger that enriches log events via the provided enrichers.
        /// </summary>
        /// <param name="enrichers">Enrichers that apply in the context.</param>
        /// <returns>A logger that will enrich log events as specified.</returns>
{'fraction_non_alphanumeric': 0.11795054260807686, 'fraction_numerical': 0.004269702899839886, 'mean_word_length': 2.1372767857142856, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3348908', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1422, 'n_words': 551}