Switch from Newtonsoft.Json to System.Text.Json in the logger
This commit is contained in:
parent
6f94de5a14
commit
7b06965f14
2 changed files with 9 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.Logger
|
||||
{
|
||||
|
@ -7,16 +8,16 @@ namespace Geekbot.Core.Logger
|
|||
{
|
||||
private readonly bool _logAsJson;
|
||||
private readonly NLog.Logger _logger;
|
||||
private readonly JsonSerializerSettings _serializerSettings;
|
||||
private readonly JsonSerializerOptions _serializerSettings;
|
||||
|
||||
public GeekbotLogger(RunParameters runParameters)
|
||||
{
|
||||
_logAsJson = !string.IsNullOrEmpty(runParameters.SumologicEndpoint) || runParameters.LogJson;
|
||||
_logger = LoggerFactory.CreateNLog(runParameters);
|
||||
_serializerSettings = new JsonSerializerSettings
|
||||
_serializerSettings = new JsonSerializerOptions
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
|
||||
NullValueHandling = NullValueHandling.Include
|
||||
ReferenceHandler = ReferenceHandler.IgnoreCycles,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||
};
|
||||
Information(LogSource.Geekbot, "Using GeekbotLogger");
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ namespace Geekbot.Core.Logger
|
|||
StackTrace = stackTrace,
|
||||
Extra = extra
|
||||
};
|
||||
return JsonConvert.SerializeObject(logObject, Formatting.None, _serializerSettings);
|
||||
return JsonSerializer.Serialize(logObject, _serializerSettings);
|
||||
}
|
||||
|
||||
if (source != LogSource.Message) return $"[{source}] - {message}";
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.Logger
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum LogSource
|
||||
{
|
||||
Geekbot,
|
||||
|
|
Loading…
Reference in a new issue