namespace OubHackMS.Logging.Handlers
{
    using OubHackMS.Core;
    using OubHackMS.Logging;
    using System;
    using System.IO;

    internal class UserLogConsole : LoggingHandler
    {
        public UserLogConsole(OubHackMS parent) : base(parent)
        {
            base.handleKey = Level.USER_LOG_CONSOLE;
        }

        public override void onLog(params object[] oArgs)
        {
            if (oArgs.Length >= 2)
            {
                string str = (string) oArgs[0];
                if (!Directory.Exists("users"))
                {
                    Directory.CreateDirectory("users");
                }
                if (!Directory.Exists("users/" + str))
                {
                    Directory.CreateDirectory("users/" + str);
                }
                if (!Directory.Exists("users/" + str + "/logs"))
                {
                    Directory.CreateDirectory("users/" + str + "/logs");
                }
                File.AppendAllText("users/" + str + "/logs/event_log.txt", DateTime.Now.ToString("[yyyy:MM:dd hh:mm:ss] ") + ("USER EVENT (" + str + ") : " + oArgs[1].ToString()) + Environment.NewLine);
                base.printTimestamp("[hh:mm:ss]");
                Console.WriteLine("USER EVENT (" + str + ") : " + oArgs[1].ToString());
            }
        }
    }
}

