using Microsoft.Extensions.Logging;

namespace PLCIOPointTool.Services;

public class LogService : ILogService
{
    public event EventHandler<LogEventArgs>? MessageReceived;

    public void Info(string message)
    {
        CreateLogContent(LogType.Info, message);
    }
    public void Warning(string message)
    {
        CreateLogContent(LogType.Warning, message);
    }
    public void Error(string message)
    {
        CreateLogContent(LogType.Error, message);
    }

    private void CreateLogContent(LogType logType, string message)
    {
        MessageReceived?.Invoke(null, new LogEventArgs(DateTime.Now, logType, message));
    }
}
