You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/10 08:44:06 UTC
[3/6] git commit: Add WrapperLogger.
Add WrapperLogger.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0a7e3a42
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0a7e3a42
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0a7e3a42
Branch: refs/heads/master
Commit: 0a7e3a42a25c6c60ff8c903963a004c1a49911b5
Parents: 07e6faa
Author: Matt Sicker <ma...@apache.org>
Authored: Wed Sep 10 01:40:29 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Wed Sep 10 01:40:29 2014 -0500
----------------------------------------------------------------------
.../apache/logging/log4j/jul/WrappedLogger.java | 75 ++++++++++++++++++++
1 file changed, 75 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0a7e3a42/log4j-jul/src/main/java/org/apache/logging/log4j/jul/WrappedLogger.java
----------------------------------------------------------------------
diff --git a/log4j-jul/src/main/java/org/apache/logging/log4j/jul/WrappedLogger.java b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/WrappedLogger.java
new file mode 100644
index 0000000..639f00c
--- /dev/null
+++ b/log4j-jul/src/main/java/org/apache/logging/log4j/jul/WrappedLogger.java
@@ -0,0 +1,75 @@
+/*
+ * 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.logging.log4j.jul;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.spi.ExtendedLogger;
+import org.apache.logging.log4j.spi.ExtendedLoggerWrapper;
+
+/**
+ * Wrapper class to ensure proper FQCN support in Logger calls.
+ */
+class WrappedLogger extends ExtendedLoggerWrapper {
+
+ private static final long serialVersionUID = 1L;
+ private static final String FQCN = ApiLogger.class.getName();
+
+ WrappedLogger(final ExtendedLogger logger) {
+ super(logger, logger.getName(), logger.getMessageFactory());
+ }
+
+ @Override
+ public void log(final Level level, final String message, final Throwable t) {
+ logIfEnabled(FQCN, level, null, message, t);
+ }
+
+ @Override
+ public void log(final Level level, final String message, final Object... params) {
+ logIfEnabled(FQCN, level, null, message, params);
+ }
+
+ @Override
+ public void log(final Level level, final String message) {
+ logIfEnabled(FQCN, level, null, message);
+ }
+
+ @Override
+ public void entry() {
+ entry(FQCN);
+ }
+
+ @Override
+ public void entry(final Object... params) {
+ entry(FQCN, params);
+ }
+
+ @Override
+ public void exit() {
+ exit(FQCN, null);
+ }
+
+ @Override
+ public <R> R exit(final R result) {
+ return exit(FQCN, result);
+ }
+
+ @Override
+ public <T extends Throwable> T throwing(final T t) {
+ return throwing(FQCN, Level.ERROR, t);
+ }
+}