Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit fd4d18c

Browse files
peterhorsleyleastprivilege
authored andcommitted
Allow LogSerializer to be disabled to facilitate usage in Unity iOS (#67)
* Allow LogSerializer to be disabled to facilitate usage in Unity iOS apps, which cannot JSON serialize objects with properties. * Ensure it's clear if log serializer is disabled, and add missing XML comment.
1 parent a2b3547 commit fd4d18c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/IdentityModel.OidcClient/Infrastructure/LogSerializer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ namespace IdentityModel.OidcClient.Infrastructure
66
/// <summary>
77
/// Helper to JSON serialize object data for logging.
88
/// </summary>
9-
internal static class LogSerializer
9+
public static class LogSerializer
1010
{
11+
/// <summary>
12+
/// Allows log serialization to be disabled, for example, for platforms
13+
/// that don't support serialization of arbitarary objects to JSON.
14+
/// </summary>
15+
public static bool Enabled = true;
16+
1117
static readonly JsonSerializerSettings jsonSettings = new JsonSerializerSettings
1218
{
1319
NullValueHandling = NullValueHandling.Ignore,
@@ -27,7 +33,7 @@ static LogSerializer()
2733
/// <returns></returns>
2834
public static string Serialize(object logObject)
2935
{
30-
return JsonConvert.SerializeObject(logObject, jsonSettings);
36+
return Enabled ? JsonConvert.SerializeObject(logObject, jsonSettings) : "Logging has been disabled";
3137
}
3238
}
3339
}

0 commit comments

Comments
 (0)