using System;
using EonaCat.LogStack.Core;

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

    public sealed class EonaCatNLogAdapter : INLogLogger
    {
        private readonly EonaCatLogStack _logger;
        public EonaCatNLogAdapter(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);
        }
    }
}
