Merge branch 'main' into develop
# Conflicts: # Server/Logger/WebApplicationLogger.cs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Core.Models.Logging;
|
||||
using Core.Models.Utils;
|
||||
using Core.Utils.Logger;
|
||||
using SptCommon.Annotations;
|
||||
using LogLevel = Core.Models.Spt.Logging.LogLevel;
|
||||
|
||||
@@ -8,11 +9,17 @@ namespace Server.Logger;
|
||||
[Injectable]
|
||||
public class SptWebApplicationLogger<T> : ISptLogger<T>
|
||||
{
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private static ILogger? _fileLogger;
|
||||
|
||||
public SptWebApplicationLogger(ILoggerProvider provider)
|
||||
{
|
||||
_logger = provider.CreateLogger(typeof(T).FullName ?? "SPT Logger Default Name");
|
||||
if (_fileLogger == null)
|
||||
{
|
||||
_fileLogger = provider.CreateLogger(typeof(FileLogger).FullName ?? "SPT Logger Default Name");
|
||||
}
|
||||
}
|
||||
|
||||
public void LogWithColor(
|
||||
@@ -62,10 +69,9 @@ public class SptWebApplicationLogger<T> : ISptLogger<T>
|
||||
_logger.LogCritical(ex, GetColorizedText(data, LogTextColor.Black, LogBackgroundColor.Red));
|
||||
}
|
||||
|
||||
public void WriteToLogFile(string data)
|
||||
public void WriteToLogFile(string body, LogLevel level = LogLevel.Info)
|
||||
{
|
||||
// TODO: implement + turn object into json
|
||||
_logger.LogError("NOT IMPLEMENTED - WriteToLogFile");
|
||||
_fileLogger?.Log(ConvertLogLevel(level), body);
|
||||
}
|
||||
|
||||
public bool IsLogEnabled(LogLevel level)
|
||||
|
||||
Reference in New Issue
Block a user