using log4net;
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.Skyscraper.Plugins
{
	public class PluginLogger
	{
		private static readonly ILog superLogger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);

		internal PluginLogger(Type type)
		{
			Type = type;
			Logger = LogManager.GetLogger(type.Name);
			superLogger.DebugFormat("Logging for {0} enabled.",type.Name);
		}

		internal Type Type { get; }
		private ILog Logger { get; set; }

		public void Log(PluginLogLevel level, string message, params object[] a)
		{
			switch(level)
			{
				case PluginLogLevel.Off:
					break;
				case PluginLogLevel.Error:
					Logger.ErrorFormat(message, a);
					break;
				case PluginLogLevel.Warn:
					Logger.WarnFormat(message, a);
					break;
				case PluginLogLevel.Info:
					Logger.InfoFormat(message, a);
					break;
				case PluginLogLevel.Debug:
					Logger.DebugFormat(message, a);
					break;
				case PluginLogLevel.All:
					//Console.WriteLine(message, a);
					break;
				default:
					throw new NotImplementedException(level.ToString());
			}
		}
	}
}
