using System;
using System.IO;
using System.Reflection;
using Interfaces;
using NLog;
using NLog.Config;

namespace NLogLogger
{
    public class NLogLoggingService : ILoggerService
    {
        private readonly Logger _logger;
        public NLogLoggingService(IConfigFilePathProvider configFileFolder)
        {
            var cfgFilePath = Path.Combine(configFileFolder.GetPath, "NLogConfig.xml");
            LogManager.Configuration = new XmlLoggingConfiguration(cfgFilePath);
            var loggerName = Assembly.GetEntryAssembly().GetName().Name;
            _logger = LogManager.GetLogger(loggerName);
            //_logger = LogManager.GetLogger("");
        }

        public bool IsDebugEnabled { get { return _logger.IsDebugEnabled; } }
        public bool IsErrorEnabled { get { return _logger.IsErrorEnabled; } }
        public bool IsFatalEnabled { get { return _logger.IsFatalEnabled; } }
        public bool IsInfoEnabled { get { return _logger.IsInfoEnabled; } }
        public bool IsTraceEnabled { get { return _logger.IsTraceEnabled; } }
        public bool IsWarnEnabled { get { return _logger.IsWarnEnabled; } }

        public void Debug(Exception exception)
        {
            _logger.Debug(exception);
        }

        public void Debug(string format, params object[] args)
        {
            _logger.Debug(format, args);
        }

        public void Debug(Exception exception, string format, params object[] args)
        {
            _logger.Debug(exception, format, args);
        }

        public void Error(Exception exception)
        {
            _logger.Error(exception);
        }

        public void Error(string format, params object[] args)
        {
            _logger.Error(format, args);
        }

        public void Error(Exception exception, string format, params object[] args)
        {
            _logger.Error(exception, format, args);
        }

        public void Fatal(Exception exception)
        {
            _logger.Error(exception);
        }

        public void Fatal(string format, params object[] args)
        {
            _logger.Fatal(format, args);
        }

        public void Fatal(Exception exception, string format, params object[] args)
        {
            _logger.Error(exception, format, args);
        }

        public void Info(Exception exception)
        {
            _logger.Info(exception);
        }

        public void Info(string format, params object[] args)
        {
            _logger.Info(format, args);
        }

        public void Info(Exception exception, string format, params object[] args)
        {
            _logger.Error(exception, format, args);
        }

        public void Trace(Exception exception)
        {
            _logger.Trace(exception);
        }

        public void Trace(string format, params object[] args)
        {
            _logger.Trace(format, args);
        }

        public void Trace(Exception exception, string format, params object[] args)
        {
            _logger.Error(exception, format, args);
        }

        public void Warn(Exception exception)
        {
            _logger.Warn(exception);
        }

        public void Warn(string format, params object[] args)
        {
            _logger.Warn(format, args);
        }

        public void Warn(Exception exception, string format, params object[] args)
        {
            _logger.Error(exception, format, args);
        }
    }
}
