/*
 *  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 httl.spi.loggers;

import httl.spi.Logger;

import java.io.Serializable;

import org.apache.log4j.Level;
import org.apache.log4j.LogManager;

/**
 * Log4jLogger
 * 
 * @author Liang Fei (liangfei0201 AT gmail DOT com)
 */
public class Log4jLogger implements Logger, Serializable {

	private static final long serialVersionUID = 1L;

	private static final org.apache.log4j.Logger logger = LogManager.getLogger(NAME);

	public void trace(String msg) {
		logger.trace(msg);
	}

	public void trace(String msg, Throwable e) {
		logger.trace(msg, e);
	}

	public void debug(String msg) {
		logger.debug(msg);
	}

	public void debug(String msg, Throwable e) {
		logger.debug(msg, e);
	}

	public void info(String msg) {
		logger.info(msg);
	}

	public void info(String msg, Throwable e) {
		logger.info(msg, e);
	}

	public void warn(String msg) {
		logger.warn(msg);
	}

	public void warn(String msg, Throwable e) {
		logger.warn(msg, e);
	}

	public void error(String msg) {
		logger.error(msg);
	}

	public void error(String msg, Throwable e) {
		logger.error(msg, e);
	}

	public boolean isTraceEnabled() {
		return logger.isTraceEnabled();
	}

	public boolean isDebugEnabled() {
		return logger.isDebugEnabled();
	}

	public boolean isInfoEnabled() {
		return logger.isInfoEnabled();
	}

	public boolean isWarnEnabled() {
		return logger.getLevel() == null || logger.getLevel().toInt() >= Level.WARN_INT;
	}

	public boolean isErrorEnabled() {
		return logger.getLevel() == null || logger.getLevel().toInt() >= Level.ERROR_INT;
	}

	public boolean isFatalEnabled() {
		return logger.getLevel() == null || logger.getLevel().toInt() >= Level.FATAL_INT;
	}

}

@@ -1187,31 +1187,24 @@
 %0A%0D%0A%09private 
-static 
 final org.ap
@@ -1257,24 +1257,145 @@
 r(NAME);%0D%0A%0D%0A
+%09private String FQCN = Log4jLogger.class.getName();%0D%0A%0D%0A%09public void setLogger(String name) %7B%0D%0A%09%09this.FQCN = name;%0D%0A%09%7D%0D%0A%0D%0A
 %09public void
@@ -1425,25 +1425,48 @@
 %09logger.
-trace(msg
+log(FQCN, Level.TRACE, msg, null
 );%0D%0A%09%7D%0D%0A
@@ -1523,22 +1523,39 @@
 %09logger.
-trace(
+log(FQCN, Level.TRACE, 
 msg, e);
@@ -1605,25 +1605,48 @@
 %09logger.
-debug(msg
+log(FQCN, Level.DEBUG, msg, null
 );%0D%0A%09%7D%0D%0A
@@ -1703,22 +1703,39 @@
 %09logger.
-debug(
+log(FQCN, Level.DEBUG, 
 msg, e);
@@ -1784,24 +1784,47 @@
 %09logger.
-info(msg
+log(FQCN, Level.INFO, msg, null
 );%0D%0A%09%7D%0D%0A
@@ -1880,21 +1880,38 @@
 %09logger.
-info(
+log(FQCN, Level.INFO, 
 msg, e);
@@ -1960,24 +1960,47 @@
 %09logger.
-warn(msg
+log(FQCN, Level.WARN, msg, null
 );%0D%0A%09%7D%0D%0A
@@ -2056,21 +2056,38 @@
 %09logger.
-warn(
+log(FQCN, Level.WARN, 
 msg, e);
@@ -2137,25 +2137,48 @@
 %09logger.
-error(msg
+log(FQCN, Level.ERROR, msg, null
 );%0D%0A%09%7D%0D%0A
@@ -2235,22 +2235,39 @@
 %09logger.
-error(
+log(FQCN, Level.ERROR, 
 msg, e);
@@ -2558,59 +2558,21 @@
 ger.
-getLevel() == null %7C%7C logger.getLevel().toInt() %3E= 
+isEnabledFor(
 Leve
@@ -2577,27 +2577,25 @@
 vel.WARN
-_INT
+)
 ;%0D%0A%09%7D%0D%0A
+%09
 %0D%0A%09publi
@@ -2617,33 +2617,36 @@
 orEnabled() %7B%0D%0A%09
-%09
+    
 return logger.ge
@@ -2647,201 +2647,33 @@
 ger.
-getLevel() == null %7C%7C logger.getLevel().toInt() %3E= Level.ERROR_INT;%0D%0A%09%7D%0D%0A%0D%0A%09public boolean isFatalEnabled() %7B%0D%0A%09%09return logger.getLevel() == null %7C%7C logger.getLevel().toInt() %3E= Level.FATAL_INT
+isEnabledFor(Level.ERROR)
 ;%0D%0A%09

modify version