<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace sones.Library.SlimLogFramework.Logger
{
    public class FileLogger: ILogger
    {
        private Level _Level;
        private StreamWriter _stream;
        private bool _disposed = false;


        public FileLogger(String myPath) : this(myPath, Level.SEVERE) { }

        public FileLogger(String myPath, Level myLevel)
        {
            this._Level = myLevel;
            _stream = File.CreateText(myPath);
            _stream.AutoFlush = true;
        }

        void ILogger.Log(string myMessage)
        {
            DoLog(Level.SEVERE, myMessage, null);
        }

        void ILogger.Log(string myMessage, params object[] myParams)
        {
            DoLog(Level.SEVERE, myMessage, myParams);
        }


        void ILogger.Log(Level myLevel, string myMessage)
        {
            DoLog(myLevel, myMessage, null);
        }

        void ILogger.Log(Level myLevel, string myMessage, params object[] myParams)
        {
            DoLog(myLevel, myMessage, myParams);
        }

        private void DoLog(Level myLevel, string myMessage, object[] myParams)
        {
            if (myLevel > _Level)
                return;

            myMessage = (myParams == null)
                ? myMessage
                : String.Format(myMessage, myParams);

            
            _stream.WriteLine(myLevel.ToString() + ": " + myMessage);
        }

        #region IDisposable Members

        public void Dispose()
        {
            if (_stream != null && ! _disposed)
            {
                _disposed = true;
                try
                {
                    _stream.Dispose();
                }
                catch (ObjectDisposedException)
                {
                    //nothing to do
                }
            }
        }

        #endregion
    }
}<commit_msg>added a timestamp in filelogger<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace sones.Library.SlimLogFramework.Logger
{
    public class FileLogger: ILogger
    {
        private Level _Level;
        private StreamWriter _stream;
        private bool _disposed = false;


        public FileLogger(String myPath) : this(myPath, Level.SEVERE) { }

        public FileLogger(String myPath, Level myLevel)
        {
            this._Level = myLevel;
            _stream = File.CreateText(myPath);
            _stream.AutoFlush = true;
        }

        void ILogger.Log(string myMessage)
        {
            DoLog(Level.SEVERE, myMessage, null);
        }

        void ILogger.Log(string myMessage, params object[] myParams)
        {
            DoLog(Level.SEVERE, myMessage, myParams);
        }


        void ILogger.Log(Level myLevel, string myMessage)
        {
            DoLog(myLevel, myMessage, null);
        }

        void ILogger.Log(Level myLevel, string myMessage, params object[] myParams)
        {
            DoLog(myLevel, myMessage, myParams);
        }

        private void DoLog(Level myLevel, string myMessage, object[] myParams)
        {
            if (myLevel > _Level)
                return;

            myMessage = (myParams == null)
                ? myMessage
                : String.Format(myMessage, myParams);

            
            _stream.WriteLine(DateTime.Now + " " + myLevel.ToString() + ": " + myMessage);
        }

        #region IDisposable Members

        public void Dispose()
        {
            if (_stream != null && ! _disposed)
            {
                _disposed = true;
                try
                {
                    _stream.Dispose();
                }
                catch (ObjectDisposedException)
                {
                    //nothing to do
                }
            }
        }

        #endregion
    }
}
{'fraction_non_alphanumeric': 0.08551129155036792, 'fraction_numerical': 0.0, 'mean_word_length': 1.462211118051218, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '4436924', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1035, 'n_words': 237}