Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E712E6BA2 for ; Mon, 25 Jul 2011 18:23:36 +0000 (UTC) Received: (qmail 17252 invoked by uid 500); 25 Jul 2011 18:23:36 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 17144 invoked by uid 500); 25 Jul 2011 18:23:35 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 17137 invoked by uid 99); 25 Jul 2011 18:23:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jul 2011 18:23:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jul 2011 18:23:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 660A9238890D for ; Mon, 25 Jul 2011 18:23:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1150823 - in /cxf/branches/2.4.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java Date: Mon, 25 Jul 2011 18:23:11 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110725182311.660A9238890D@eris.apache.org> Author: dkulp Date: Mon Jul 25 18:23:10 2011 New Revision: 1150823 URL: http://svn.apache.org/viewvc?rev=1150823&view=rev Log: Merged revisions 1150820 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1150820 | dkulp | 2011-07-25 14:20:20 -0400 (Mon, 25 Jul 2011) | 2 lines [CXF-3680] Logging locations are hidden with Slf4jLogger Patch from Woonsan Ko applied ........ Modified: cxf/branches/2.4.x-fixes/ (props changed) cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java Propchange: cxf/branches/2.4.x-fixes/ ('svn:mergeinfo' removed) Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java?rev=1150823&r1=1150822&r2=1150823&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java (original) +++ cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java Mon Jul 25 18:23:10 2011 @@ -21,6 +21,8 @@ package org.apache.cxf.common.logging; import java.util.logging.Level; import java.util.logging.LogRecord; +import org.slf4j.spi.LocationAwareLogger; + /** *

* java.util.logging.Logger implementation delegating to SLF4J. @@ -46,11 +48,17 @@ import java.util.logging.LogRecord; */ public class Slf4jLogger extends AbstractDelegatingLogger { + private static final String FQCN = AbstractDelegatingLogger.class.getName(); + private final org.slf4j.Logger logger; + private LocationAwareLogger locationAwareLogger; public Slf4jLogger(String name, String resourceBundleName) { super(name, resourceBundleName); logger = org.slf4j.LoggerFactory.getLogger(name); + if (logger instanceof LocationAwareLogger) { + locationAwareLogger = (LocationAwareLogger) logger; + } } @Override @@ -85,23 +93,55 @@ public class Slf4jLogger extends Abstrac * comparisons is important. We first try log level FINE then INFO, WARN, FINER, etc */ if (Level.FINE.equals(level)) { - logger.debug(msg, t); + if (locationAwareLogger == null) { + logger.debug(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t); + } } else if (Level.INFO.equals(level)) { - logger.info(msg, t); + if (locationAwareLogger == null) { + logger.info(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, t); + } } else if (Level.WARNING.equals(level)) { - logger.warn(msg, t); + if (locationAwareLogger == null) { + logger.warn(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, t); + } } else if (Level.FINER.equals(level)) { - logger.trace(msg, t); + if (locationAwareLogger == null) { + logger.trace(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t); + } } else if (Level.FINEST.equals(level)) { - logger.trace(msg, t); + if (locationAwareLogger == null) { + logger.trace(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t); + } } else if (Level.ALL.equals(level)) { // should never occur, all is used to configure java.util.logging // but not accessible by the API Logger.xxx() API - logger.error(msg, t); + if (locationAwareLogger == null) { + logger.error(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t); + } } else if (Level.SEVERE.equals(level)) { - logger.error(msg, t); + if (locationAwareLogger == null) { + logger.error(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t); + } } else if (Level.CONFIG.equals(level)) { - logger.debug(msg, t); + if (locationAwareLogger == null) { + logger.debug(msg, t); + } else { + locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t); + } } else if (Level.OFF.equals(level)) { // don't log }