From a78c957255251105b87d47cb06b4df598b124377 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 18 May 2021 21:43:36 +0200 Subject: LogEntry: Tolerate null file, line, and function fields. Change-Id: I555132fbcedd4a01923f3d0dcd0e90c22284e840 --- .../quarkus/googlecloud/jsonlogging/LogEntry.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java index 4c70e6f..2be17a2 100644 --- a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java +++ b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java @@ -70,11 +70,21 @@ final class LogEntry { } JsonObject json() { - return Json.createObjectBuilder() - .add("file", file) - .add("line", line) - .add("function", function) - .build(); + var b = Json.createObjectBuilder(); + + if (file != null) { + b.add("file", file); + } + + if (line != null) { + b.add("line", line); + } + + if (function != null) { + b.add("function", function); + } + + return b.build(); } } -- cgit v1.2.3