You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2020/11/12 16:48:38 UTC
[logging-log4j2] 01/03: Improve JTL TemplateResolver docs.
This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 749ef1373749480fe1a0cfd84100d7e3d9b89d73
Author: Volkan Yazıcı <vo...@gmail.com>
AuthorDate: Wed Nov 11 16:34:38 2020 +0100
Improve JTL TemplateResolver docs.
---
.../template/json/resolver/TemplateResolver.java | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TemplateResolver.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TemplateResolver.java
index 5db3813..62ce41d 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TemplateResolver.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TemplateResolver.java
@@ -21,20 +21,47 @@ import org.apache.logging.log4j.layout.template.json.util.JsonWriter;
@FunctionalInterface
public interface TemplateResolver<V> {
+ /**
+ * Indicates if the resolution should be appended to the parent JSON object.
+ * <p>
+ * For instance, {@link ThreadContextDataResolver}, i.e., MDC resolver,
+ * uses this flag to indicate whether the contents should be appended to the
+ * parent JSON object or not.
+ */
default boolean isFlattening() {
return false;
}
+ /**
+ * Indicates if the resolver if applicable at all.
+ * <p>
+ * For instance, the source line resolver can be short-circuited using this
+ * check if the location information is disabled in the layout configuration.
+ */
default boolean isResolvable() {
return true;
}
+ /**
+ * Indicates if the resolver if applicable for the given {@code value}.
+ * <p>
+ * For instance, the stack trace resolver can be short-circuited using this
+ * check if the stack traces are disabled in the layout configuration.
+ */
default boolean isResolvable(V value) {
return true;
}
+ /**
+ * Resolves the given {@code value} using the provided {@link JsonWriter}.
+ */
void resolve(V value, JsonWriter jsonWriter);
+ /**
+ * Resolves the given {@code value} using the provided {@link JsonWriter}.
+ *
+ * @param succeedingEntry false, if this is the first element in a collection; true, otherwise
+ */
default void resolve(V value, JsonWriter jsonWriter, boolean succeedingEntry) {
resolve(value, jsonWriter);
}