Browse Source
Use TruncateWithPostfix for JSON truncation in FormatDataValue
pull/25267/head
maliming
6 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
1 additions and
8 deletions
-
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 |
|
|
|
{ |
|
|
|
|