namespace decePubClient.Services; public interface ILoggingService { ValueTask ProcessError(Exception exception, string where, CancellationToken cancellationToken = default); ValueTask ProcessError(string message, string where, CancellationToken cancellationToken = default); ValueTask ProcessWarning(string message, string where, CancellationToken cancellationToken = default); void Process(string message, string where = default, LogLevel level = LogLevel.Information); } /// Writes to the browser console through ILogger. public class LoggingService(ILogger logger) : ILoggingService { public void Process(string message, string where = default, LogLevel level = LogLevel.Information) => logger.Log(level, "[{Where}] {Message}", where ?? "N/A", message); public ValueTask ProcessError(Exception exception, string where, CancellationToken cancellationToken = default) { logger.LogError(exception, "[{Where}]", where); return ValueTask.CompletedTask; } public ValueTask ProcessError(string message, string where, CancellationToken cancellationToken = default) { logger.LogError("[{Where}] {Message}", where, message); return ValueTask.CompletedTask; } public ValueTask ProcessWarning(string message, string where, CancellationToken cancellationToken = default) { logger.LogWarning("[{Where}] {Message}", where, message); return ValueTask.CompletedTask; } }