Improved logging
This commit is contained in:
@@ -5,15 +5,14 @@ namespace Core.Models.Utils;
|
||||
|
||||
public interface ISptLogger<T>
|
||||
{
|
||||
// TODO: Removing these 4 methods for now, revisit in the future
|
||||
// void WriteToLogFile(string data);
|
||||
// TODO: Removing these methods for now, revisit in the future
|
||||
// void Log(string data, LogTextColor? color, string? backgroundColor = null);
|
||||
void LogWithColor(string data, Exception? ex = null, LogTextColor? textColor = null, LogBackgroundColor? backgroundColor = null);
|
||||
void LogWithColor(string data, LogTextColor? textColor = null, LogBackgroundColor? backgroundColor = null, Exception? ex = null);
|
||||
void Success(string data, Exception? ex = null);
|
||||
void Error(string data, Exception? ex = null);
|
||||
void Warning(string data, Exception? ex = null);
|
||||
void Info(string data, Exception? ex = null);
|
||||
void Debug(string data, Exception? ex = null);
|
||||
void Critical(string data, Exception? ex = null);
|
||||
void WriteToLogFile(object body);
|
||||
void WriteToLogFile(string body);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using Core.Annotations;
|
||||
using Core.DI;
|
||||
using Core.Helpers;
|
||||
using Core.Models.Eft.HttpResponse;
|
||||
using Core.Models.Eft.ItemEvent;
|
||||
using Core.Models.Enums;
|
||||
using Core.Models.Utils;
|
||||
using Core.Services;
|
||||
using Core.Utils;
|
||||
using Core.Utils.Cloners;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Core.Routers
|
||||
{
|
||||
@@ -16,7 +13,8 @@ namespace Core.Routers
|
||||
public class ItemEventRouter
|
||||
{
|
||||
protected ISptLogger<ItemEventRouter> _logger;
|
||||
private readonly HttpResponseUtil _httpResponseUtil;
|
||||
protected HttpResponseUtil _httpResponseUtil;
|
||||
protected JsonUtil _jsonUtil;
|
||||
protected ProfileHelper _profileHelper;
|
||||
protected LocalisationService _localisationService;
|
||||
protected EventOutputHolder _eventOutputHolder;
|
||||
@@ -26,6 +24,7 @@ namespace Core.Routers
|
||||
public ItemEventRouter(
|
||||
ISptLogger<ItemEventRouter> logger,
|
||||
HttpResponseUtil httpResponseUtil,
|
||||
JsonUtil jsonUtil,
|
||||
ProfileHelper profileHelper,
|
||||
LocalisationService localisationService,
|
||||
EventOutputHolder eventOutputHolder,
|
||||
@@ -35,6 +34,7 @@ namespace Core.Routers
|
||||
{
|
||||
_logger = logger;
|
||||
_httpResponseUtil = httpResponseUtil;
|
||||
_jsonUtil = jsonUtil;
|
||||
_profileHelper = profileHelper;
|
||||
_localisationService = localisationService;
|
||||
_eventOutputHolder = eventOutputHolder;
|
||||
@@ -53,7 +53,7 @@ namespace Core.Routers
|
||||
if (eventRouter is null)
|
||||
{
|
||||
_logger.Error(_localisationService.GetText("event-unhandled_event", body.Action));
|
||||
_logger.WriteToLogFile(body);
|
||||
_logger.WriteToLogFile(_jsonUtil.Serialize(info.Data));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ public class SptWebApplicationLogger<T> : ISptLogger<T>
|
||||
|
||||
public void LogWithColor(
|
||||
string data,
|
||||
Exception? ex = null,
|
||||
LogTextColor? textColor = null,
|
||||
LogBackgroundColor? backgroundColor = null
|
||||
LogBackgroundColor? backgroundColor = null,
|
||||
Exception? ex = null
|
||||
)
|
||||
{
|
||||
if (textColor != null || backgroundColor != null)
|
||||
@@ -83,7 +83,7 @@ public class SptWebApplicationLogger<T> : ISptLogger<T>
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void WriteToLogFile(object data)
|
||||
public void WriteToLogFile(string data)
|
||||
{
|
||||
//TODO - implement + turn object into json
|
||||
_logger.LogError("NOT IMPLEMENTED - WriteToLogFile");
|
||||
|
||||
Reference in New Issue
Block a user