diff options
21 files changed, 162 insertions, 95 deletions
diff --git a/README.adoc b/README.adoc index 253d3d7..e69ccc3 100644 --- a/README.adoc +++ b/README.adoc @@ -48,7 +48,7 @@ If you are using Maven: <dependency> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging</artifactId> - <version>6.5.0</version> + <version>6.6.0</version> </dependency> </dependencies> @@ -59,7 +59,7 @@ If you are using Gradle: [source,groovy] ---- dependencies { - implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging:6.5.0") + implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging:6.6.0") } ---- @@ -91,7 +91,7 @@ If you are using Maven: <dependency> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-core</artifactId> - <version>6.5.0</version> + <version>6.6.0</version> </dependency> </dependencies> @@ -102,7 +102,7 @@ If you are using Gradle: [source,groovy] ---- dependencies { - implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.5.0") + implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.6.0") } ---- @@ -125,7 +125,7 @@ If you are using Maven: <dependency> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-core</artifactId> - <version>6.5.0</version> + <version>6.6.0</version> </dependency> <dependency> @@ -142,7 +142,7 @@ If you are using Gradle: [source,groovy] ---- dependencies { - implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.5.0") + implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.6.0") implementation("org.jboss.logmanager:jboss-logmanager:3.0.2.Final") } ---- @@ -186,7 +186,7 @@ If you are using Maven: <dependency> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-core</artifactId> - <version>6.5.0</version> + <version>6.6.0</version> </dependency> <dependency> @@ -249,7 +249,7 @@ configurations { } dependencies { - implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.5.0") + implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.6.0") implementation("org.jboss.logmanager:jboss-logmanager:3.0.2.Final") implementation("org.jboss.logmanager:jboss-logmanager-embedded:1.2.0.Final") implementation("org.jboss.slf4j:slf4j-jboss-logmanager:2.0.1.Final") @@ -311,28 +311,28 @@ Logging unstructured data requires no code changes. All logs are automatically converted to Google-Cloud-Logging-compatible JSON. Structured data can be logged in one of 3 different ways: by passing -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/Label.html[Label]s +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/Label.html[Label]s and -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameter.html[StructuredParameter]s +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameter.html[StructuredParameter]s as parameters to individual log entries, by supplying -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.html[LabelProvider]s +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.html[LabelProvider]s and -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.html[StructuredParameterProvider]s, +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.html[StructuredParameterProvider]s, or by using the Mapped Diagnostic Context. === Using Label and StructuredParameter Instances of -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/Label.html[Label] +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/Label.html[Label] and -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameter.html[StructuredParameter] +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameter.html[StructuredParameter] can be passed as log parameters to the `*f` family of logging functions on JBoss Logging's https://docs.jboss.org/jbosslogging/latest/org/jboss/logging/Logger.html[Logger]. Simple key–value pairs are represented by -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.html[KeyValueParameter]. +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.html[KeyValueParameter]. **Example:** @@ -367,9 +367,9 @@ Result: === Using LabelProvider and StructuredParameterProvider Any CDI beans that implement -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.html[LabelProvider] +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.html[LabelProvider] and -https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.5.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.html[StructuredParameterProvider] +https://javadocs.dev/eu.mulk.quarkus-googlecloud-jsonlogging/quarkus-googlecloud-jsonlogging-core/6.6.0/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.html[StructuredParameterProvider] are discovered at build time and consulted to provide labels and parameters for each message that is logged. This can be used to provide contextual information such as tracing and request IDs stored diff --git a/core/pom.xml b/core/pom.xml index a8140b4..7320b24 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -14,7 +14,7 @@ SPDX-License-Identifier: LGPL-3.0-or-later <parent> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId> - <version>6.5.1-SNAPSHOT</version> + <version>6.6.1-SNAPSHOT</version> </parent> <artifactId>quarkus-googlecloud-jsonlogging-core</artifactId> @@ -38,41 +38,47 @@ SPDX-License-Identifier: LGPL-3.0-or-later <version>2.1.3</version> </dependency> <dependency> - <groupId>io.smallrye.common</groupId> - <artifactId>smallrye-common-constraint</artifactId> - <version>2.4.0</version> + <groupId>org.jspecify</groupId> + <artifactId>jspecify</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>io.github.eisop</groupId> + <artifactId>checker-qual</artifactId> + <version>3.42.0-eisop4</version> + <scope>provided</scope> </dependency> <!-- Include Parsson for backwards-compatibility. --> <dependency> <groupId>org.eclipse.parsson</groupId> <artifactId>parsson</artifactId> - <version>1.1.6</version> + <version>1.1.7</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> - <version>5.10.3</version> + <version>5.11.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> - <version>5.10.3</version> + <version>5.11.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-core</artifactId> - <version>1.35</version> + <version>1.37</version> <scope>test</scope> </dependency> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-generator-annprocess</artifactId> - <version>1.35</version> + <version>1.37</version> <scope>test</scope> </dependency> </dependencies> @@ -83,14 +89,53 @@ SPDX-License-Identifier: LGPL-3.0-or-later <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> + <fork>true</fork> <annotationProcessorPaths> <path> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-generator-annprocess</artifactId> - <version>1.35</version> + <version>1.37</version> + </path> + <path> + <groupId>io.github.eisop</groupId> + <artifactId>checker</artifactId> + <version>3.42.0-eisop4</version> </path> </annotationProcessorPaths> + <annotationProcessors> + <annotationProcessor>org.checkerframework.checker.nullness.NullnessChecker</annotationProcessor> + </annotationProcessors> + <compilerArgs> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg> + <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg> + <arg>-Xmaxerrs</arg> + <arg>10000</arg> + <arg>-Xmaxwarns</arg> + <arg>10000</arg> + </compilerArgs> </configuration> + <executions> + <execution> + <id>default-compile</id> + <configuration> + </configuration> + </execution> + <execution> + <id>default-testCompile</id> + <configuration> + <annotationProcessors> + <annotationProcessor>org.openjdk.jmh.generators.BenchmarkProcessor</annotationProcessor> + </annotationProcessors> + </configuration> + </execution> + </executions> </plugin> <plugin> diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Formatter.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Formatter.java index 0b2003d..9c66f82 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Formatter.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Formatter.java @@ -6,17 +6,13 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; import java.io.PrintWriter; import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ServiceLoader; +import java.util.*; import java.util.ServiceLoader.Provider; import java.util.logging.Level; import java.util.stream.Collectors; import org.jboss.logmanager.ExtFormatter; import org.jboss.logmanager.ExtLogRecord; +import org.jspecify.annotations.Nullable; /** * Formats log records as JSON for consumption by Google Cloud Logging. @@ -42,7 +38,7 @@ public class Formatter extends ExtFormatter { private final List<StructuredParameterProvider> parameterProviders; private final List<LabelProvider> labelProviders; - private final ThreadLocal<StringBuilder> stringBuilder; + private final ThreadLocal<@Nullable StringBuilder> stringBuilder; /** * Constructs a {@link Formatter} with custom configuration. @@ -125,8 +121,9 @@ public class Formatter extends ExtFormatter { String insertId = null; - if (logRecord.getParameters() != null) { - for (var parameter : logRecord.getParameters()) { + var logRecordParameters = logRecord.getParameters(); + if (logRecordParameters != null) { + for (var parameter : logRecordParameters) { if (parameter instanceof StructuredParameter) { parameters.add((StructuredParameter) parameter); } else if (parameter instanceof Label) { @@ -158,7 +155,7 @@ public class Formatter extends ExtFormatter { logRecord.getLevel().intValue() >= 1000 ? ERROR_EVENT_TYPE : null, insertId); - var b = stringBuilder.get(); + var b = Objects.requireNonNull(stringBuilder.get()); b.delete(0, b.length()); b.append("{"); entry.json(b); @@ -166,7 +163,7 @@ public class Formatter extends ExtFormatter { return b.toString(); } - private static LogEntry.SourceLocation sourceLocationOf(ExtLogRecord logRecord) { + private static LogEntry.@Nullable SourceLocation sourceLocationOf(ExtLogRecord logRecord) { var sourceFileName = logRecord.getSourceFileName(); var sourceLineNumber = logRecord.getSourceLineNumber(); var sourceClassName = logRecord.getSourceClassName(); @@ -191,9 +188,10 @@ public class Formatter extends ExtFormatter { var messagePrintWriter = new PrintWriter(messageStringWriter); messagePrintWriter.append(this.formatMessage(logRecord)); - if (logRecord.getThrown() != null) { + var logRecordThrown = logRecord.getThrown(); + if (logRecordThrown != null) { messagePrintWriter.println(); - logRecord.getThrown().printStackTrace(messagePrintWriter); + logRecordThrown.printStackTrace(messagePrintWriter); } messagePrintWriter.close(); @@ -230,9 +228,9 @@ public class Formatter extends ExtFormatter { private static class ProviderContext implements LabelProvider.Context, StructuredParameterProvider.Context { - private final String loggerName; + private final @Nullable String loggerName; private final long sequenceNumber; - private final String threadName; + private final @Nullable String threadName; private ProviderContext(ExtLogRecord logRecord) { loggerName = logRecord.getLoggerName(); @@ -241,7 +239,7 @@ public class Formatter extends ExtFormatter { } @Override - public String loggerName() { + public @Nullable String loggerName() { return loggerName; } @@ -251,7 +249,7 @@ public class Formatter extends ExtFormatter { } @Override - public String threadName() { + public @Nullable String threadName() { return threadName; } } diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/InsertId.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/InsertId.java index b55cf78..48b376c 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/InsertId.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/InsertId.java @@ -5,17 +5,18 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; import java.util.Objects; +import org.jspecify.annotations.Nullable; /** * A unique identifier for a log entry. * - * <p>Prevents the duplicate insertion of log entries. Also serves as a discriminator to order log entries that carry - * the same time stamp. + * <p>Prevents the duplicate insertion of log entries. Also serves as a discriminator to order log + * entries that carry the same time stamp. * * <p>Will be generated by Google Cloud Logging if not provided. * - * <p>Instances of {@link InsertId} can be passed as log parameters to the {@code *f} family of logging - * functions on {@link org.jboss.logging.Logger}. + * <p>Instances of {@link InsertId} can be passed as log parameters to the {@code *f} family of + * logging functions on {@link org.jboss.logging.Logger}. * * <p><strong>Example:</strong> * @@ -63,7 +64,7 @@ public final class InsertId { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; var that = (InsertId) obj; diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java index a2c468b..9e16aab 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/KeyValueParameter.java @@ -10,6 +10,7 @@ import jakarta.json.spi.JsonProvider; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Objects; +import org.jspecify.annotations.Nullable; /** * A simple single key–value pair forming a {@link StructuredParameter}. @@ -168,7 +169,7 @@ public final class KeyValueParameter implements StructuredParameter { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; var that = (KeyValueParameter) obj; diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Label.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Label.java index d5a9000..2696185 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Label.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/Label.java @@ -5,6 +5,7 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; import java.util.Objects; +import org.jspecify.annotations.Nullable; /** * A label usable to tag a log message. @@ -78,7 +79,7 @@ public final class Label { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; var that = (Label) obj; diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.java index 0298042..2bc0349 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LabelProvider.java @@ -5,6 +5,7 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; import java.util.Collection; +import org.jspecify.annotations.Nullable; /** * A user-supplied provider for {@link Label}s. @@ -52,7 +53,7 @@ public interface LabelProvider { * @return a collection of {@link Label}s to add to each log entry that is logged. * @see #getLabels(Context) */ - default Collection<Label> getLabels() { + default @Nullable Collection<Label> getLabels() { return null; } @@ -63,7 +64,7 @@ public interface LabelProvider { * * @return a collection of {@link Label}s to add to each log entry that is logged. */ - default Collection<Label> getLabels(Context context) { + default @Nullable Collection<Label> getLabels(Context context) { return getLabels(); } diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java index 2d08c29..d335ee4 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/LogEntry.java @@ -4,12 +4,12 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; -import io.smallrye.common.constraint.Nullable; import jakarta.json.JsonString; import jakarta.json.JsonValue; import java.time.Instant; import java.util.List; import java.util.Map; +import org.jspecify.annotations.Nullable; /** * A JSON log entry compatible with Google Cloud Logging. @@ -27,15 +27,15 @@ final class LogEntry { private final String message; private final String severity; private final Timestamp timestamp; - @Nullable private final String trace; - @Nullable private final String spanId; - @Nullable private final SourceLocation sourceLocation; + private final @Nullable String trace; + private final @Nullable String spanId; + private final @Nullable SourceLocation sourceLocation; private final Map<String, String> labels; private final List<StructuredParameter> parameters; private final Map<String, String> mappedDiagnosticContext; - @Nullable private final String nestedDiagnosticContext; - @Nullable private final String type; - @Nullable private final String insertId; + private final @Nullable String nestedDiagnosticContext; + private final @Nullable String type; + private final @Nullable String insertId; LogEntry( String message, @@ -66,9 +66,9 @@ final class LogEntry { static final class SourceLocation { - @Nullable private final String file; - @Nullable private final String line; - @Nullable private final String function; + private final @Nullable String file; + private final @Nullable String line; + private final @Nullable String function; SourceLocation(@Nullable String file, @Nullable String line, @Nullable String function) { this.file = file; diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/ProviderContext.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/ProviderContext.java index 08b399a..93f7a7a 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/ProviderContext.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/ProviderContext.java @@ -5,6 +5,7 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; import org.jboss.logmanager.ExtLogRecord; +import org.jspecify.annotations.Nullable; /** * Contextual data available to {@link StructuredParameterProvider} and {@link LabelProvider}. @@ -19,7 +20,7 @@ public interface ProviderContext { * * @return {@link ExtLogRecord#getLoggerName()}. */ - String loggerName(); + @Nullable String loggerName(); /** * The {@link ExtLogRecord#getSequenceNumber()} property of the log record that is being @@ -34,5 +35,5 @@ public interface ProviderContext { * * @return {@link ExtLogRecord#getThreadName()}. */ - String threadName(); + @Nullable String threadName(); } diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.java index d78f0d8..c02516c 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/StructuredParameterProvider.java @@ -4,6 +4,8 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; +import org.jspecify.annotations.Nullable; + /** * A user-supplied provider for {@link StructuredParameter}s. * @@ -58,7 +60,7 @@ public interface StructuredParameterProvider { * @return a {@link StructuredParameter} to add to each log entry that is logged. * @see #getParameter(Context) */ - default StructuredParameter getParameter() { + default @Nullable StructuredParameter getParameter() { return null; } @@ -73,7 +75,7 @@ public interface StructuredParameterProvider { * * @return a {@link StructuredParameter} to add to each log entry that is logged. */ - default StructuredParameter getParameter(Context context) { + default @Nullable StructuredParameter getParameter(Context context) { return getParameter(); } diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/package-info.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/package-info.java index 3b6f38c..d36dfc1 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/package-info.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/package-info.java @@ -19,4 +19,7 @@ * when used in conjunction with frameworks other than Quarkus (such as Spring Boot). See the class * documentation for details. */ +@NullMarked package eu.mulk.quarkus.googlecloud.jsonlogging.logmanager; + +import org.jspecify.annotations.NullMarked; diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/package-info.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/package-info.java index a84f1fc..17133c4 100644 --- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/package-info.java +++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/package-info.java @@ -43,7 +43,7 @@ * <dependency> * <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> * <artifactId>quarkus-googlecloud-jsonlogging-core</artifactId> - * <version>6.5.0</version> + * <version>6.6.0</version> * </dependency> * * ... @@ -59,7 +59,7 @@ * dependencies { * // ... * - * implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.5.0") + * implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging-core:6.6.0") * * // ... * } @@ -198,4 +198,7 @@ * } * } */ +@NullMarked package eu.mulk.quarkus.googlecloud.jsonlogging; + +import org.jspecify.annotations.NullMarked; diff --git a/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterBenchmark.java b/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterBenchmark.java index c330dfe..7bbdac6 100644 --- a/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterBenchmark.java +++ b/core/src/test/java/eu/mulk/quarkus/googlecloud/jsonlogging/FormatterBenchmark.java @@ -4,8 +4,11 @@ package eu.mulk.quarkus.googlecloud.jsonlogging; +import static java.util.logging.Level.FINEST; + import java.util.List; -import org.jboss.logmanager.ExtLogRecord; +import java.util.logging.LogRecord; +import org.jboss.logmanager.formatters.Formatters; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; @@ -15,11 +18,14 @@ import org.openjdk.jmh.infra.Blackhole; @State(org.openjdk.jmh.annotations.Scope.Benchmark) public class FormatterBenchmark { - private ExtLogRecord simpleLogRecord; - private ExtLogRecord structuredLogRecord; - private ExtLogRecord massivelyStructuredLogRecord; - private ExtLogRecord nestedLogRecord; - private Formatter formatter; + private static final LogRecord NULL_LOG_RECORD = new LogRecord(FINEST, ""); + private static final java.util.logging.Formatter NULL_FORMATTER = Formatters.nullFormatter(); + + private LogRecord simpleLogRecord = NULL_LOG_RECORD; + private LogRecord structuredLogRecord = NULL_LOG_RECORD; + private LogRecord massivelyStructuredLogRecord = NULL_LOG_RECORD; + private LogRecord nestedLogRecord = NULL_LOG_RECORD; + private java.util.logging.Formatter formatter = NULL_FORMATTER; @Setup public void setup() { diff --git a/deployment/pom.xml b/deployment/pom.xml index e668986..17b19fe 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -14,7 +14,7 @@ SPDX-License-Identifier: LGPL-3.0-or-later <parent> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId> - <version>6.5.1-SNAPSHOT</version> + <version>6.6.1-SNAPSHOT</version> </parent> <artifactId>quarkus-googlecloud-jsonlogging-deployment</artifactId> diff --git a/examples/quarkus/pom.xml b/examples/quarkus/pom.xml index 8557223..5cda438 100644 --- a/examples/quarkus/pom.xml +++ b/examples/quarkus/pom.xml @@ -14,7 +14,7 @@ SPDX-License-Identifier: GPL-3.0-or-later <parent> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId> - <version>6.5.0</version> + <version>6.6.0</version> </parent> <artifactId>quarkus-googlecloud-jsonlogging-quarkus-example</artifactId> diff --git a/examples/spring-boot/pom.xml b/examples/spring-boot/pom.xml index 0125aed..8bc1023 100644 --- a/examples/spring-boot/pom.xml +++ b/examples/spring-boot/pom.xml @@ -16,7 +16,7 @@ SPDX-License-Identifier: GPL-3.0-or-later <parent> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId> - <version>6.5.0</version> + <version>6.6.0</version> </parent> <artifactId>quarkus-googlecloud-jsonlogging-spring-boot-example</artifactId> @@ -12,7 +12,7 @@ SPDX-License-Identifier: LGPL-3.0-or-later <modelVersion>4.0.0</modelVersion> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> - <version>6.5.1-SNAPSHOT</version> + <version>6.6.1-SNAPSHOT</version> <artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId> <packaging>pom</packaging> @@ -61,18 +61,18 @@ SPDX-License-Identifier: LGPL-3.0-or-later <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <compiler-plugin.version>3.13.0</compiler-plugin.version> - <exec-maven-plugin.version>3.2.0</exec-maven-plugin.version> + <exec-maven-plugin.version>3.4.1</exec-maven-plugin.version> <failsafe-plugin.version>${surefire-plugin.version}</failsafe-plugin.version> <flatten-plugin.version>1.6.0</flatten-plugin.version> - <jar-plugin.version>3.4.1</jar-plugin.version> - <maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version> - <maven-javadoc-plugin.version>3.7.0</maven-javadoc-plugin.version> + <jar-plugin.version>3.4.2</jar-plugin.version> + <maven-gpg-plugin.version>3.2.5</maven-gpg-plugin.version> + <maven-javadoc-plugin.version>3.8.0</maven-javadoc-plugin.version> <maven-source-plugin.version>3.3.1</maven-source-plugin.version> <nexus-staging-plugin.version>1.7.0</nexus-staging-plugin.version> <spotless-plugin.version>2.43.0</spotless-plugin.version> - <surefire-plugin.version>3.2.5</surefire-plugin.version> + <surefire-plugin.version>3.4.0</surefire-plugin.version> - <quarkus.version>3.11.1</quarkus.version> + <quarkus.version>3.14.0</quarkus.version> </properties> <distributionManagement> diff --git a/runtime/pom.xml b/runtime/pom.xml index 952463d..04a9e35 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -14,7 +14,7 @@ SPDX-License-Identifier: LGPL-3.0-or-later <parent> <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> <artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId> - <version>6.5.1-SNAPSHOT</version> + <version>6.6.1-SNAPSHOT</version> </parent> <artifactId>quarkus-googlecloud-jsonlogging</artifactId> diff --git a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java index 21a4ca9..72d1cfa 100644 --- a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java +++ b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java @@ -4,19 +4,24 @@ package eu.mulk.quarkus.googlecloud.jsonlogging.runtime; -import io.quarkus.runtime.annotations.ConfigItem; -import io.quarkus.runtime.annotations.ConfigPhase; +import static io.quarkus.runtime.annotations.ConfigPhase.RUN_TIME; + import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; +import io.smallrye.config.WithParentName; /** Configuration for console logging in Google Cloud Logging JSON format. */ -@ConfigRoot(prefix = "quarkus.log.console", name = "google", phase = ConfigPhase.RUN_TIME) -public class GoogleCloudJsonLoggingConfiguration { +@ConfigMapping(prefix = "quarkus.log.console.google") +@ConfigRoot(phase = RUN_TIME) +public interface GoogleCloudJsonLoggingConfiguration { /** * Whether to enable Google Cloud Logging JSON logging to <code>stdout</code>/<code>stderr</code>. * * <p>Replaces the regular plain-text format for console logs. */ - @ConfigItem(defaultValue = "true", name = ConfigItem.PARENT) - public boolean enabled; + @WithDefault("true") + @WithParentName + boolean enabled(); } diff --git a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java index af09231..74b63c6 100644 --- a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java +++ b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java @@ -28,7 +28,7 @@ public class GoogleCloudJsonLoggingRecorder { */ public RuntimeValue<Optional<java.util.logging.Formatter>> initialize( GoogleCloudJsonLoggingConfiguration configuration) { - if (!configuration.enabled) { + if (!configuration.enabled()) { return new RuntimeValue<>(Optional.empty()); } diff --git a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/package-info.java b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/package-info.java index bdfa657..d20a203 100644 --- a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/package-info.java +++ b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/package-info.java @@ -43,7 +43,7 @@ * <dependency> * <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId> * <artifactId>quarkus-googlecloud-jsonlogging</artifactId> - * <version>6.5.0</version> + * <version>6.6.0</version> * </dependency> * * ... @@ -59,7 +59,7 @@ * dependencies { * // ... * - * implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging:6.5.0") + * implementation("eu.mulk.quarkus-googlecloud-jsonlogging:quarkus-googlecloud-jsonlogging:6.6.0") * * // ... * } |