Skip to content

Commit

Permalink
minor log
Browse files Browse the repository at this point in the history
  • Loading branch information
tvatavuk committed Sep 28, 2023
1 parent 70f05db commit 1c14796
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Write(Utf8JsonWriter writer, T? pair, JsonSerializerOptions

public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Logger.LogInformation($"2sic# Reading DesignSettingsJsonConverter {typeof(T)} / {typeToConvert}.");
Logger.LogInformation($"cre8magic# Reading DesignSettingsJsonConverter {typeof(T)} / {typeToConvert}.");
var jsonNode = JsonNode.Parse(ref reader);

const string errArray = "Error unexpected data - array instead of string or object";
Expand Down
10 changes: 5 additions & 5 deletions ToSic.Cre8Magic.Client/Settings/Json/JsonConverterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ protected JsonSerializerOptions GetOptionsWithoutThisConverter(JsonSerializerOpt
{
if (IsInsideConverter)
{
Logger.LogInformation("2sic# Already inside converter {Converter}", this);
Logger.LogInformation("cre8magic# Already inside converter {Converter}", this);
return options; // Return the original options if we're already inside the converter
}

JsonSerializerOptions optionsWithoutConverter = new(options);
if (!optionsWithoutConverter.Converters.Remove(this))
Logger.LogWarning("2sic# Could not remove converter {Converter} from options", this);
Logger.LogWarning("cre8magic# Could not remove converter {Converter} from options", this);
else
Logger.LogInformation("2sic# Removed converter {Converter} from options", this);
Logger.LogInformation("cre8magic# Removed converter {Converter} from options", this);
return optionsWithoutConverter;
}

protected T? ConvertObject(JsonObject jsonObject, JsonSerializerOptions options)
{
try
{
Logger.LogInformation("2sic# Deserializing {Type} from {Json}", typeof(T), jsonObject);
Logger.LogInformation("cre8magic# Deserializing {Type} from {Json}", typeof(T), jsonObject);

IsInsideConverter = true;
var result = jsonObject.Deserialize<T>(GetOptionsWithoutThisConverter(options));
Expand All @@ -55,7 +55,7 @@ protected JsonSerializerOptions GetOptionsWithoutThisConverter(JsonSerializerOpt
}
catch
{
Logger.LogError("2sic# Error while deserializing {Type} from {Json}", typeof(T), jsonObject);
Logger.LogError("cre8magic# Error while deserializing {Type} from {Json}", typeof(T), jsonObject);
IsInsideConverter = false; // Ensure the flag is reset even if an exception occurs
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion ToSic.Cre8Magic.Client/Settings/PairOnOffJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override void Write(Utf8JsonWriter writer, PairOnOff? pair, JsonSerialize

public override PairOnOff? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Logger.LogInformation($"2sic# Reading PairOnOffJsonConverter / {typeToConvert}.");
Logger.LogInformation($"cre8magic# Reading PairOnOffJsonConverter / {typeToConvert}.");
var x = JsonNode.Parse(ref reader);
return x switch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void Write(Utf8JsonWriter writer, MagicThemePartSettings? part,

public override MagicThemePartSettings? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Logger.LogInformation($"2sic# Reading ThemePartJsonConverter / {typeToConvert}.");
Logger.LogInformation($"cre8magic# Reading ThemePartJsonConverter / {typeToConvert}.");
var x = JsonNode.Parse(ref reader);
return x switch
{
Expand Down

0 comments on commit 1c14796

Please sign in to comment.