You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2022/01/01 05:15:00 UTC

[logging-log4j2] 01/02: [LOG4J2-3267] add public Generate#generateExtend/Custom methods for automation

This is an automated email from the ASF dual-hosted git repository.

rpopma pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 4e3ae472fc943c3774bd646374566ba8d5d5dc73
Author: rpopma <rp...@apache.org>
AuthorDate: Sat Jan 1 12:10:01 2022 +0900

    [LOG4J2-3267] add public Generate#generateExtend/Custom methods for automation
---
 .../apache/logging/log4j/core/tools/Generate.java  | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
index cf49a53..2bf35b4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
@@ -1061,6 +1061,30 @@ public final class Generate {
         generate(args, type, System.out);
     }
 
+    /**
+     * Generates source code for extended logger wrappers that provide convenience methods for the specified custom
+     * levels.
+     *
+     * @param args className of the custom logger to generate, followed by a NAME=intLevel pair for each custom log
+     *            level to generate convenience methods for
+     * @param printStream the stream to write the generated source code to
+     */
+    public static void generateExtend(final String[] args, final PrintStream printStream) {
+        generate(args, Type.EXTEND, printStream);
+    }
+
+    /**
+     * Generates source code for custom logger wrappers that only provide convenience methods for the specified
+     * custom levels, not for the standard built-in levels.
+     *
+     * @param args className of the custom logger to generate, followed by a NAME=intLevel pair for each custom log
+     *            level to generate convenience methods for
+     * @param printStream the stream to write the generated source code to
+     */
+    public static void generateCustom(final String[] args, final PrintStream printStream) {
+        generate(args, Type.CUSTOM, printStream);
+    }
+
     static void generate(final String[] args, final Type type, final PrintStream printStream) {
         if (!validate(args)) {
             usage(printStream, type.generator());