in src/Google.Cloud.Functions.Hosting/Logging/JsonConsoleLogger.cs [136:169]
private static void WriteScope(object? value, Utf8JsonWriter writer)
{
if (value is null)
{
return;
}
// Detect "first scope" and start the scopes array property.
if (writer.CurrentDepth == NoScopesDepth)
{
writer.WritePropertyName("scopes");
writer.WriteStartArray();
}
if (value is IEnumerable<KeyValuePair<string, object>> kvps)
{
writer.WriteStartObject();
foreach (var pair in kvps)
{
string key = pair.Key;
if (string.IsNullOrEmpty(key))
{
continue;
}
writer.WritePropertyName(key);
writer.WriteStringValue(ToInvariantString(pair.Value));
}
writer.WriteEndObject();
}
else
{
// TODO: Consider special casing integers etc.
writer.WriteStringValue(ToInvariantString(value));
}
}