﻿using System;
using System.IO;
using System.Threading.Tasks;

namespace Ylp.GitDb.Core
{
    public interface ILogger
    {
        Task Log(string message);
    }

    public class Logger : ILogger
    {
        public readonly string FileName;

        public Logger(string fileName)
        {
            FileName = fileName;
        }

        public Task Log(string message)
        {
            File.AppendAllText(FileName, $"{DateTime.Now.ToString("HH:mm:ss")}: {message}\n");
            return Task.CompletedTask;
        }
    }
}
﻿using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;

namespace Ylp.GitDb.Core
{
    public interface ILogger
    {
        Task Log(string message);
    }

    public class Logger : ILogger
    {
        public readonly string FileName;
        static readonly object LockObj = new object();

        public Logger(string fileName)
        {
            FileName = fileName;
        }

        public Task Log(string message)
        {
            lock(LockObj)
                File.AppendAllText(FileName, $"{DateTime.Now.ToString("HH:mm:ss")}: {message}\n");

            return Task.CompletedTask;
        }
    }
}
Make sure logging doesn't cause cross-thread access to the log-file
Bugfix: Make sure logging doesn't cause cross-thread access to the log-file
