using System;
using EonaCat.LogStack.Core;

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

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

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