using System;
using System.IO;

namespace LauncherUpdater.Function
{
    public class Logger
    {
        public static void WriteLog(string strLog)
        {
            string path = Configuration.Default.LauncherDir + nameof(Logger);
            Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, "Top-Level Folder");
            Directory.CreateDirectory(path);
            string str = path + "/Log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".txt";
            FileInfo fileInfo = new FileInfo(str);
            DirectoryInfo directoryInfo = new DirectoryInfo(fileInfo.DirectoryName);
            if (!directoryInfo.Exists)
                directoryInfo.Create();
            StreamWriter streamWriter = new StreamWriter(fileInfo.Exists
                ? (Stream) new FileStream(str, FileMode.Append)
                : (Stream) fileInfo.Create());
            streamWriter.WriteLine("\r\nLog Entry : ");
            DateTime now = DateTime.Now;
            string longTimeString = now.ToLongTimeString();
            now = DateTime.Now;
            string longDateString = now.ToLongDateString();
            streamWriter.WriteLine("{0} {1}", (object) longTimeString, (object) longDateString);
            streamWriter.WriteLine("  :");
            streamWriter.WriteLine("  :{0}", (object) strLog);
            streamWriter.WriteLine("-------------------------------");
            streamWriter.Close();
        }
    }
}