using YMhut.Box.Core.Logging;

namespace YMhut.Box.Core.Plugins;

public sealed class PluginLogService(ILogService logService)
{
    public Task WriteAsync(
        string pluginId,
        string level,
        string message,
        string? detail = null,
        CancellationToken cancellationToken = default)
    {
        return logService.WriteAsync(level, $"plugin:{pluginId}", message, detail, cancellationToken);
    }

    public Task<IReadOnlyList<LogEntry>> ReadAsync(
        string pluginId,
        int take = 200,
        CancellationToken cancellationToken = default)
    {
        return logService.ReadAsync(category: $"plugin:{pluginId}", take: take, cancellationToken: cancellationToken);
    }
}
