001/* 002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.importer.log; 023 024import org.apache.commons.logging.Log; 025 026/** 027 * Simple logger that wraps a bufferized string logger (for remote retrieval) and a log4J logger 028 * 029 * @author tiry 030 */ 031public class BasicLogger implements ImporterLogger { 032 033 protected Log javaLogger; 034 035 protected boolean bufferActive = false; 036 037 public BasicLogger(Log javaLogger) { 038 this.javaLogger = javaLogger; 039 } 040 041 public void info(String message) { 042 javaLogger.info(message); 043 } 044 045 public void warn(String message) { 046 javaLogger.warn(message); 047 } 048 049 public void debug(String message) { 050 javaLogger.debug(message); 051 } 052 053 public void debug(String message, Throwable t) { 054 javaLogger.debug(message, t); 055 } 056 057 public void error(String message) { 058 javaLogger.error(message); 059 } 060 061 public void error(String message, Throwable t) { 062 javaLogger.error(message, t); 063 } 064 065 public String getLoggerBuffer(String sep) { 066 return ""; 067 } 068 069 public String getLoggerBuffer() { 070 if (bufferActive) { 071 return getLoggerBuffer("\n"); 072 } else { 073 return "Buffer is not active"; 074 } 075 } 076 077 public boolean isBufferActive() { 078 return bufferActive; 079 } 080 081 public void setBufferActive(boolean active) { 082 bufferActive = active; 083 } 084 085}