<commit_before>﻿/*
 * Copyright (c) <NAME>, <NAME>.  All rights reserved.
 * see license
 */
using System;
using System.Diagnostics;

namespace Thinktecture.IdentityServer.Core.Logging
{
    public class DiagnosticsTraceLogProvider : ILogProvider
    {
        public ILog GetLogger(string name)
        {
            return new DiagnosticsTraceLogger(name);
        }
    }

    public class DiagnosticsTraceLogger : ILog
    {
        private readonly string _name = string.Empty;

        public DiagnosticsTraceLogger(string name)
        {
            _name = string.Format("[{0}]: ", name);
        }

        public void Log(LogLevel logLevel, Func<string> messageFunc)
        {
            Trace.WriteLine(_name + messageFunc(), logLevel.ToString());
        }

        public void Log<TException>(LogLevel logLevel, Func<string> messageFunc, TException exception) where TException : Exception
        {
            Trace.WriteLine(_name + messageFunc() + ": " + exception.ToString(), logLevel.ToString());<commit_msg>Added timestamp to trace log provider - see #165<commit_after>﻿/*
 * Copyright (c) <NAME>, <NAME>.  All rights reserved.
 * see license
 */
using System;
using System.Diagnostics;

namespace Thinktecture.IdentityServer.Core.Logging
{
    public class DiagnosticsTraceLogProvider : ILogProvider
    {
        public ILog GetLogger(string name)
        {
            return new DiagnosticsTraceLogger(name);
        }
    }

    public class DiagnosticsTraceLogger : ILog
    {
        private readonly string _name = string.Empty;

        public DiagnosticsTraceLogger(string name)
        {
            _name = string.Format("[{0}]", name);
        }

        public void Log(LogLevel logLevel, Func<string> messageFunc)
        {
            var message = string.Format("{0}: {1} -- {2}", _name, DateTime.UtcNow.ToString(), messageFunc());

            Trace.WriteLine(message, logLevel.ToString());
        }

        public void Log<TException>(LogLevel logLevel, Func<string> messageFunc, TException exception) where TException : Exception
        {
            var message = string.Format("{0}: {1} -- {2}\n{3}", _name, DateTime.UtcNow.ToString(), messageFunc(), exception.ToString());

            Trace.WriteLine(message, logLevel.ToString());
{'fraction_non_alphanumeric': 0.11150131694468832, 'fraction_numerical': 0.0052677787532923615, 'mean_word_length': 2.699675324675325, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 13, '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': '2014035', 'n_tokens_mistral': 611, 'n_tokens_neox': 600, 'n_words': 152}