<commit_before>﻿// ReflectInsight
// Copyright (c) 2017 ReflectSoftware.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Internal;
using ReflectSoftware.Insight;
using ReflectSoftware.Insight.Common;
using RI.Utils.ExceptionManagement;
using System;
using System.Collections.Specialized;
using System.Text;

namespace ReflectInsight.Extensions.Logging
{
    /// <summary>
    /// 
    /// </summary>
    /// <seealso cref="Microsoft.Extensions.Logging.ILogger" />
    public interface IReflectInsightLogger: ILogger
    {
        IReflectInsight GetLogger();
    }

    /// <summary>
    /// 
    /// </summary>
    /// <seealso cref="Microsoft.Extensions.Logging.IReflectInsightLogger" />
    public class ReflectInsightLogger : IReflectInsightLogger
    {
        private readonly string _name;
        
        /// <summary>
        /// Initializes a new instance of the <see cref="ReflectInsightLogger"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public ReflectInsightLogger(string name)
        {
            _name = name;
        }

        /// <summary>
        /// Begins a logical operation scope.
        /// </summary>
        /// <typeparam name="TState">The type of the state.</typeparam>
        /// <param name="state">The identifier for the scope.</param>
        /// <returns>
        /// An IDisposable that ends the logical operation scope on dispose.
        /// </returns>
        public IDisposable BeginScope<TState>(TState state)
        {
            var formatter = (state as FormattedLogValues);
            var message = formatter?.ToString() ?? (state.ToString() ?? string.Empty);
            
            if(message.IndexOf("Microsoft.EntityFrameworkCore", StringComparison.OrdinalIgnoreCase) < 0)
            {
                return null;
            }

            return GetLogger().TraceMethod(message);
        }
<commit_msg>Intercepting EF Core commands and displaying them as SQL commands arguments.<commit_after>﻿// ReflectInsight
// Copyright (c) 2017 ReflectSoftware.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Internal;
using ReflectSoftware.Insight;
using ReflectSoftware.Insight.Common;
using RI.Utils.ExceptionManagement;
using System;
using System.Collections.Specialized;
using System.Text;

namespace ReflectInsight.Extensions.Logging
{
    /// <summary>
    /// 
    /// </summary>
    /// <seealso cref="Microsoft.Extensions.Logging.ILogger" />
    public interface IReflectInsightLogger: ILogger
    {
        IReflectInsight GetLogger();
    }

    /// <summary>
    /// 
    /// </summary>
    /// <seealso cref="Microsoft.Extensions.Logging.IReflectInsightLogger" />
    public class ReflectInsightLogger : IReflectInsightLogger
    {
        private readonly string _name;
        
        /// <summary>
        /// Initializes a new instance of the <see cref="ReflectInsightLogger"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public ReflectInsightLogger(string name)
        {
            _name = name;
        }

        /// <summary>
        /// Begins a logical operation scope.
        /// </summary>
        /// <typeparam name="TState">The type of the state.</typeparam>
        /// <param name="state">The identifier for the scope.</param>
        /// <returns>
        /// An IDisposable that ends the logical operation scope on dispose.
        /// </returns>
        public IDisposable BeginScope<TState>(TState state)
        {
            var formatter = (state as FormattedLogValues);
            var message = formatter?.ToString() ?? (state.ToString() ?? string.Empty);
            
            if(message.IndexOf("Microsoft.EntityFrameworkCore", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                return null;
            }

            return GetLogger().TraceMethod(message);
        }

{'fraction_non_alphanumeric': 0.11710843373493976, 'fraction_numerical': 0.0033734939759036144, 'mean_word_length': 2.2531347962382444, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, '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': '3434487', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1078, 'n_words': 276}