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 2016/04/05 17:52:57 UTC
[05/23] logging-log4j2 git commit: Re-use AbstractLoggerAdapter.
Re-use AbstractLoggerAdapter.
Issues: LOG4J2-1336.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/cf606938
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/cf606938
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/cf606938
Branch: refs/heads/LOG4J2-1343-no-gc-outputstreamappenders
Commit: cf60693834b269effe31fc17749025205cdaaefa
Parents: d69fb83
Author: Matt Sicker <bo...@gmail.com>
Authored: Mon Apr 4 14:32:57 2016 -0500
Committer: Matt Sicker <bo...@gmail.com>
Committed: Mon Apr 4 14:33:07 2016 -0500
----------------------------------------------------------------------
.../main/java/org/apache/log4j/Category.java | 26 +++++++-------
.../apache/log4j/spi/LoggerFactoryBridge.java | 36 --------------------
2 files changed, 14 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cf606938/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
index e3e68a0..873aa0e 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
@@ -25,13 +25,13 @@ import java.util.concurrent.ConcurrentMap;
import org.apache.log4j.helpers.NullEnumeration;
import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.spi.LoggerFactoryBridge;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.util.NameUtil;
import org.apache.logging.log4j.message.LocalizedMessage;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.ObjectMessage;
+import org.apache.logging.log4j.spi.AbstractLoggerAdapter;
import org.apache.logging.log4j.util.Strings;
@@ -40,7 +40,7 @@ import org.apache.logging.log4j.util.Strings;
*/
public class Category {
- private static LoggerFactoryBridge loggerFactory = new PrivateFactory();
+ private static PrivateAdapter adapter = new PrivateAdapter();
private static final Map<LoggerContext, ConcurrentMap<String, Logger>> CONTEXT_MAP =
new WeakHashMap<>();
@@ -76,11 +76,11 @@ public class Category {
}
public static Category getInstance(final String name) {
- return getInstance(PrivateManager.getContext(), name, loggerFactory);
+ return getInstance(PrivateManager.getContext(), name, adapter);
}
static Logger getInstance(final LoggerContext context, final String name) {
- return getInstance(context, name, loggerFactory);
+ return getInstance(context, name, adapter);
}
static Logger getInstance(final LoggerContext context, final String name, final LoggerFactory factory) {
@@ -94,13 +94,13 @@ public class Category {
return prev == null ? logger : prev;
}
- static Logger getInstance(final LoggerContext context, final String name, final LoggerFactoryBridge factory) {
+ static Logger getInstance(final LoggerContext context, final String name, final PrivateAdapter factory) {
final ConcurrentMap<String, Logger> loggers = getLoggersMap(context);
Logger logger = loggers.get(name);
if (logger != null) {
return logger;
}
- logger = factory.makeNewLoggerInstance(context, name);
+ logger = factory.newLogger(name, context);
final Logger prev = loggers.putIfAbsent(name, logger);
return prev == null ? logger : prev;
}
@@ -453,14 +453,16 @@ public class Category {
}
}
- /**
- * Private logger factory.
- */
- private static class PrivateFactory implements LoggerFactoryBridge {
+ private static class PrivateAdapter extends AbstractLoggerAdapter<Logger> {
+
+ @Override
+ protected Logger newLogger(final String name, final org.apache.logging.log4j.spi.LoggerContext context) {
+ return new Logger((LoggerContext) context, name);
+ }
@Override
- public Logger makeNewLoggerInstance(org.apache.logging.log4j.core.LoggerContext context, final String name) {
- return new Logger(context, name);
+ protected org.apache.logging.log4j.spi.LoggerContext getContext() {
+ return PrivateManager.getContext();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cf606938/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerFactoryBridge.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerFactoryBridge.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerFactoryBridge.java
deleted file mode 100644
index bd14ab3..0000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerFactoryBridge.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Logger;
-
-/**
- *
- * Implement this interface to create new instances of Logger or a sub-class of Logger when instantiating with specific
- * context.
- *
- * <p>
- * See <code>examples/subclass/MyLogger.java</code> for an example.
- * </p>
- *
- * @since 2.6
- */
-public interface LoggerFactoryBridge {
-
- Logger makeNewLoggerInstance(org.apache.logging.log4j.core.LoggerContext context, String name);
-
-}
\ No newline at end of file