Browse Source

Use TruncateWithPostfix for JSON truncation in FormatDataValue

pull/25267/head
maliming 6 months ago
parent
commit
02c7dae2a1
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 9
      framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs

9
framework/src/Volo.Abp.Core/Microsoft/Extensions/Logging/AbpLoggerExtensions.cs

@ -100,7 +100,6 @@ public static class AbpLoggerExtensions
}
private const int MaxDataValueLength = 4096;
private const string TruncationSuffix = "...(truncated)";
private static string FormatDataValue(object? value)
{
@ -117,13 +116,7 @@ public static class AbpLoggerExtensions
try
{
var json = JsonSerializer.Serialize(value);
if (json.Length > MaxDataValueLength)
{
return json.Substring(0, MaxDataValueLength - TruncationSuffix.Length) + TruncationSuffix;
}
return json;
return JsonSerializer.Serialize(value).TruncateWithPostfix(MaxDataValueLength, "...(truncated)")!;
}
catch
{

Loading…
Cancel
Save