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 @Override 042 public void info(String message) { 043 javaLogger.info(message); 044 } 045 046 @Override 047 public void warn(String message) { 048 javaLogger.warn(message); 049 } 050 051 @Override 052 public void debug(String message) { 053 javaLogger.debug(message); 054 } 055 056 @Override 057 public void debug(String message, Throwable t) { 058 javaLogger.debug(message, t); 059 } 060 061 @Override 062 public void error(String message) { 063 javaLogger.error(message); 064 } 065 066 @Override 067 public void error(String message, Throwable t) { 068 javaLogger.error(message, t); 069 } 070 071 @Override 072 public String getLoggerBuffer(String sep) { 073 return ""; 074 } 075 076 @Override 077 public String getLoggerBuffer() { 078 if (bufferActive) { 079 return getLoggerBuffer("\n"); 080 } else { 081 return "Buffer is not active"; 082 } 083 } 084 085 @Override 086 public boolean isBufferActive() { 087 return bufferActive; 088 } 089 090 @Override 091 public void setBufferActive(boolean active) { 092 bufferActive = active; 093 } 094 095}