using Common.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CsvCount_ES
{
    public class LogService
    {
        private static ILog _logdebug = LogManager.GetLogger("logdebug");
        private static ILog _loginfo = LogManager.GetLogger("loginfo");
        private static ILog _logwarn = LogManager.GetLogger("logwarn");
        private static ILog _logerror = LogManager.GetLogger("logerror");
        private static ILog _logfatal = LogManager.GetLogger("logfatal");


        public static void WriteDebug(string msg)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logdebug.Debug(msg);
        }


        public static void WriteDebug(string msg, Exception e)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logdebug.Debug(msg, e);
        }


        public static void WriteInfo(string msg)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _loginfo.Info(msg);
        }
        public static void WriteInfo(string msg, Exception e)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _loginfo.Info(msg, e);
        }




        public static void WriteWarn(string msg)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logwarn.Warn(msg);
        }
        public static void WriteWarn(string msg, Exception e)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logwarn.Warn(msg, e);
        }


        public static void WriteError(string msg)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logerror.Error(msg);
        }


        public static void WriteError(string msg, Exception e)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logerror.Error(msg, e);
        }


        public static void WriteFatal(string msg)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logfatal.Fatal(msg);
        }


        public static void WriteFatal(string msg, Exception e)
        {
            StackFrame sf = new StackFrame(1);
            msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg);
            _logfatal.Fatal(msg, e);
        }
    }
}
