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

[logging-log4j2] 01/02: Add ContextUtil.shutdown(LoggerContext) and Javadoc.

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 6815d628e62c5b219357e6f5ade9f59630617dbb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 13 09:18:32 2022 -0500

    Add ContextUtil.shutdown(LoggerContext) and Javadoc.
---
 .../org/apache/log4j/legacy/core/ContextUtil.java  | 26 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/ContextUtil.java b/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/ContextUtil.java
index d3b99fa..8980980 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/ContextUtil.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/ContextUtil.java
@@ -19,16 +19,32 @@ package org.apache.log4j.legacy.core;
 import org.apache.logging.log4j.spi.LoggerContext;
 
 /**
- * Implements LoggerContext methods specific to log4j-core.
+ * Delegates to {@code LoggerContext} methods implemented by {@code log4j-core} if appropriate.
  */
 public final class ContextUtil {
 
-    private ContextUtil() {
+    /**
+     * Delegates to {@link org.apache.logging.log4j.core.LoggerContext#reconfigure()} if appropriate.
+     * 
+     * @param loggerContext The target logger context.
+     */
+    public static void reconfigure(LoggerContext loggerContext) {
+        if (loggerContext instanceof org.apache.logging.log4j.core.LoggerContext) {
+            ((org.apache.logging.log4j.core.LoggerContext) loggerContext).reconfigure();
+        }
     }
 
-    public static void reconfigure(LoggerContext ctx) {
-        if (ctx instanceof org.apache.logging.log4j.core.LoggerContext) {
-            ((org.apache.logging.log4j.core.LoggerContext) ctx).reconfigure();
+    /**
+     * Delegates to {@link org.apache.logging.log4j.core.LoggerContext#close()} if appropriate.
+     * 
+     * @param loggerContext The target logger context.
+     */
+    public static void shutdown(LoggerContext loggerContext) {
+        if (loggerContext instanceof org.apache.logging.log4j.core.LoggerContext) {
+            ((org.apache.logging.log4j.core.LoggerContext) loggerContext).close();
         }
     }
+
+    private ContextUtil() {
+    }
 }