using AyCode.Core.Enums; using AyCode.Core.Loggers; using AyCode.Services.Loggers; using Microsoft.JSInterop; namespace TIAMWebApp.Shared.Application.Utility; //public interface IBrowserConsoleLogWriter : IAcLogWriterBase //{ } //public abstract class LogWriterClient : AcTextLogWriterBase //{ // protected LogWriterClient(IJSRuntime jsRuntime) : base(AppType.Web, LogLevel.Debug) // { } //} public class BrowserConsoleLogWriter : AcTextLogWriterBase, IAcLogWriterClientBase { private readonly IJSRuntime _jsRuntime; private readonly Dictionary _invokeConsoleNames = new() { [LogLevel.Detail] = "console.info", //trace [LogLevel.Trace] = "console.info", [LogLevel.Debug] = "console.info", [LogLevel.Info] = "console.info", [LogLevel.Suggest] = "console.info", [LogLevel.Warning] = "console.warn", [LogLevel.Error] = "console.error" }; public BrowserConsoleLogWriter(IJSRuntime jsRuntime) : base(AppType.Web, LogLevel.Info) { _jsRuntime = jsRuntime; } protected override void WriteText(string? logText, LogLevel logLevel) { _jsRuntime.InvokeVoidAsync(_invokeConsoleNames[logLevel], logText); //logText?.Replace(Environment.NewLine, "
")); } //public void Info(string message) //{ // ((AcLogWriterBase)this).Info(message); // //jsRuntime.InvokeVoidAsync("console.log", logText); //} }