using System;
using EonaCat.LogStack.Core;

namespace EonaCat.LogStack.Compatibility
{
    public interface ILog4NetLogger
    {
        void Log(string level, string message, Exception exception = null);
    }

    public sealed class EonaCatLog4NetAdapter : ILog4NetLogger
    {
        private readonly EonaCatLogStack _logger;
        public EonaCatLog4NetAdapter(EonaCatLogStack logger) { _logger = logger; }
        public void Log(string level, string message, Exception exception = null)
        {
            if (!Enum.TryParse(level, true, out LogLevel parsed))
            {
                parsed = LogLevel.Information;
            }

            _logger.Log(parsed, exception, message);
        }
    }
}
