summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-05-18 21:43:36 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-05-18 21:43:36 +0200
commita78c957255251105b87d47cb06b4df598b124377 (patch)
treef55712615559e2c3908328c7a86409ccc040273e /runtime
parent9d459310d0b55a7fc637089c47548f6e85edca02 (diff)
LogEntry: Tolerate null file, line, and function fields.
Change-Id: I555132fbcedd4a01923f3d0dcd0e90c22284e840
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java20
1 files changed, 15 insertions, 5 deletions
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();
}
}