cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdami...@apache.org
Subject svn commit: r1414669 - in /cocoon/branches/BRANCH_2_1_X: src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java status.xml
Date Wed, 28 Nov 2012 13:28:09 GMT
Author: cdamioli
Date: Wed Nov 28 13:28:08 2012
New Revision: 1414669

URL: http://svn.apache.org/viewvc?rev=1414669&view=rev
Log:
COCOON-2288 Allow usage of SLF4J for traces 

Added:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java
  (with props)
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java
  (with props)
Modified:
    cocoon/branches/BRANCH_2_1_X/status.xml

Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java?rev=1414669&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java
Wed Nov 28 13:28:08 2012
@@ -0,0 +1,107 @@
+/*
+ * 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.cocoon.util.log;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Avalon Logger wrapping a slf4j logger.
+ * 
+ * @author <a href="mailto:cdamioli@apache.org">Cédric Damioli</a>
+ * @author <a href="mailto:lmedioni@temenos.com">Laurent Medioni</a>
+ * @version $Id$
+ */
+public class SLF4JLoggerAdapter implements Logger {
+
+    private org.slf4j.Logger slf4jLogger;
+    
+    public SLF4JLoggerAdapter(org.slf4j.Logger slf4jLogger) {
+        this.slf4jLogger = slf4jLogger;
+    }
+
+    public void debug(String message, Throwable throwable) {
+        this.slf4jLogger.debug(message, throwable);
+    }
+
+    public void debug(String message) {
+        this.slf4jLogger.debug(message); 
+    }
+
+    public void error(String message, Throwable throwable) {
+        this.slf4jLogger.error(message, throwable);
+    }
+
+    public void error(String message) {
+        this.slf4jLogger.error(message);
+    }
+
+    public void fatalError(String message, Throwable throwable) {
+        this.slf4jLogger.error(message, throwable);
+    }
+
+    public void fatalError(String message) {
+        this.slf4jLogger.error(message);
+    }
+
+    public Logger getChildLogger(String name) {
+        String current = this.slf4jLogger.getName();
+        org.slf4j.Logger child = null;
+        if (current == null || current.trim().length() == 0){
+            child = LoggerFactory.getLogger(name);              
+        } else {
+            child = LoggerFactory.getLogger(slf4jLogger.getName() + "." + name);
+        }
+        return new SLF4JLoggerAdapter(child);
+    }
+
+    public void info(String message, Throwable throwable) {
+        this.slf4jLogger.info(message, throwable);       
+    }
+
+    public void info(String message) {
+        this.slf4jLogger.info(message);  
+    }
+
+    public boolean isDebugEnabled() {
+        return this.slf4jLogger.isDebugEnabled();
+    }
+
+    public boolean isErrorEnabled() {
+        return this.slf4jLogger.isErrorEnabled();
+    }
+
+    public boolean isFatalErrorEnabled() {
+        return this.slf4jLogger.isErrorEnabled();
+    }
+
+    public boolean isInfoEnabled() {
+        return this.slf4jLogger.isInfoEnabled();
+    }
+
+    public boolean isWarnEnabled() {
+        return this.slf4jLogger.isWarnEnabled();
+    }
+
+    public void warn(String message, Throwable throwable) {
+        this.slf4jLogger.warn(message, throwable);
+    }
+
+    public void warn(String message) {
+        this.slf4jLogger.warn(message);
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java?rev=1414669&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java
Wed Nov 28 13:28:08 2012
@@ -0,0 +1,50 @@
+/*
+ * 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.cocoon.util.log;
+
+import org.apache.avalon.excalibur.logger.AbstractLoggerManager;
+import org.apache.avalon.excalibur.logger.LoggerManager;
+import org.apache.avalon.framework.logger.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class implements a LoggerManager with a direct delegation to slf4j.
+ * 
+ * @author <a href="mailto:cdamioli@apache.org">Cédric Damioli</a>
+ * @author <a href="mailto:lmedioni@temenos.com">Laurent Medioni</a>
+ * @version $Id$
+ */
+public class SLF4JLoggerManager extends AbstractLoggerManager implements LoggerManager {
+
+    /**
+     * @param prefix
+     * @param switchTo
+     * @param defaultLoggerOverride
+     */
+    public SLF4JLoggerManager(String prefix, String switchTo, Logger defaultLoggerOverride)
{
+        super(prefix, switchTo, defaultLoggerOverride);
+    }
+    
+    public SLF4JLoggerManager(){
+        super(null, null, null);
+    }
+    
+    protected Logger doGetLoggerForCategory(String fullCategoryName) {
+        org.slf4j.Logger logger = LoggerFactory.getLogger(fullCategoryName);
+        return new SLF4JLoggerAdapter(logger);
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/log/SLF4JLoggerManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=1414669&r1=1414668&r2=1414669&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Wed Nov 28 13:28:08 2012
@@ -188,6 +188,9 @@
     <action dev="all" type="update">
       Starting with 2.1.12 the minimum required Java version will be 1.4.2.
     </action>
+    <action dev="CD" type="add" fixes-bug="COCOON-2288" due-to="Laurent Medioni" due-to-email="lmedioni@temenos.com">
+      Allow usage of SLF4J for traces
+    </action>
     <action dev="CD" type="fix" fixes-bug="COCOON-1529" due-to="Johannes Textor">
       I18nTranformer should consume and stop propagating start/endPrefixMapping of its namespace
     </action>



Mime
View raw message