NopLogWriter fixes; SignalRLogger fixes; etc...

This commit is contained in:
Loretta 2025-09-05 06:18:01 +02:00
parent a1f7c8af2d
commit 60f0071ade
1 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Core.Enums;
using AyCode.Entities;
using AyCode.Entities.Server.LogItems;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Org.BouncyCastle.Utilities.IO;
using Nop.Core.Domain.Logging;
using Nop.Services.Logging;
using LogLevel = AyCode.Core.Loggers.LogLevel;
namespace Mango.Nop.Core.Loggers
{
public class NopLogWriter : AcLogItemWriterBase<AcLogItem>//AcTextLogWriterBase
{
private readonly ILogger _nopLogger;
public NopLogWriter(ILogger nopLogger) : this(nopLogger, null)
{ }
public NopLogWriter(ILogger nopLogger, string? categoryName = null) : base(categoryName)
{
_nopLogger = nopLogger;
}
//public NopLogWriter(ILogger nopLogger, AppType appType, LogLevel logLevel, string? categoryName = null) : base(appType, logLevel, categoryName)
//{
// _nopLogger=nopLogger;
//}
protected override void WriteLogItemCallback(AcLogItem logItem)
{
switch (logItem.LogLevel)
{
case LogLevel.Detail:
case LogLevel.Trace:
case LogLevel.Debug:
case LogLevel.Info:
_nopLogger.Information(logItem.Text);
break;
case LogLevel.Suggest:
case LogLevel.Warning:
_nopLogger.Warning(logItem.Text);
break;
case LogLevel.Error:
_nopLogger.Error(logItem.Text);//, logItem.Exception);
break;
case LogLevel.Disabled:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}