001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.importer.log;
021
022import org.apache.commons.logging.Log;
023
024/**
025 * Simple logger that wraps a bufferized string logger (for remote retrieval) and a log4J logger
026 *
027 * @author tiry
028 */
029public class BasicLogger implements ImporterLogger {
030
031    protected Log javaLogger;
032
033    protected boolean bufferActive = false;
034
035    public BasicLogger(Log javaLogger) {
036        this.javaLogger = javaLogger;
037    }
038
039    public void info(String message) {
040        javaLogger.info(message);
041    }
042
043    public void warn(String message) {
044        javaLogger.warn(message);
045    }
046
047    public void debug(String message) {
048        javaLogger.debug(message);
049    }
050
051    public void debug(String message, Throwable t) {
052        javaLogger.debug(message, t);
053    }
054
055    public void error(String message) {
056        javaLogger.error(message);
057    }
058
059    public void error(String message, Throwable t) {
060        javaLogger.error(message, t);
061    }
062
063    public String getLoggerBuffer(String sep) {
064        return "";
065    }
066
067    public String getLoggerBuffer() {
068        if (bufferActive) {
069            return getLoggerBuffer("\n");
070        } else {
071            return "Buffer is not active";
072        }
073    }
074
075    public boolean isBufferActive() {
076        return bufferActive;
077    }
078
079    public void setBufferActive(boolean active) {
080        bufferActive = active;
081    }
082
083}