From a4a6b0d94977054285bc6f2a57365cae78b2394e Mon Sep 17 00:00:00 2001 From: Ben Bierens <39762930+benbierens@users.noreply.github.com> Date: Fri, 26 Apr 2024 10:25:02 +0200 Subject: [PATCH] Fix log topics (#14) adds serde log topics moves `logScope` into routine scope due to a bug in chronicles --- serde/json/deserializer.nim | 7 ++++--- serde/json/serializer.nim | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/serde/json/deserializer.nim b/serde/json/deserializer.nim index de7b620..d555be2 100644 --- a/serde/json/deserializer.nim +++ b/serde/json/deserializer.nim @@ -27,9 +27,6 @@ export types {.push raises: [].} -logScope: - topics = "json deserialization" - template expectJsonKind( expectedType: type, expectedKinds: set[JsonNodeKind], json: JsonNode ) = @@ -188,6 +185,10 @@ proc fromJson*[T: ref object or object](_: type T, json: JsonNode): ?!T = let isOptionalValue = typeof(value) is Option var skip = false # workaround for 'continue' not supported in a 'fields' loop + # logScope moved into proc due to chronicles issue: https://github.com/status-im/nim-chronicles/issues/148 + logScope: + topics = "serde json deserialization" + case mode of Strict: if opts.key notin json: diff --git a/serde/json/serializer.nim b/serde/json/serializer.nim index db9d2e6..ddd8a4c 100644 --- a/serde/json/serializer.nim +++ b/serde/json/serializer.nim @@ -20,9 +20,6 @@ export types {.push raises: [].} -logScope: - topics = "json serialization" - proc `%`*(s: string): JsonNode = newJString(s) @@ -99,6 +96,10 @@ proc `%`*[T: object or ref object](obj: T): JsonNode = let hasSerialize = value.hasCustomPragma(serialize) var skip = false # workaround for 'continue' not supported in a 'fields' loop + # logScope moved into proc due to chronicles issue: https://github.com/status-im/nim-chronicles/issues/148 + logScope: + topics = "serde json serialization" + case mode of OptIn: if not hasSerialize: