001/* 002 * $Id: LoggerFactory.java 4863 2011-05-12 07:01:55Z redlab_b $ 003 * 004 * This file is part of the iText (R) project. Copyright (c) 1998-2011 1T3XT 005 * BVBA Authors: Bruno Lowagie, Paulo Soares, et al. 006 * 007 * This program is free software; you can redistribute it and/or modify it under 008 * the terms of the GNU Affero General Public License version 3 as published by 009 * the Free Software Foundation with the addition of the following permission 010 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED 011 * WORK IN WHICH THE COPYRIGHT IS OWNED BY 1T3XT, 1T3XT DISCLAIMS THE WARRANTY 012 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. 013 * 014 * This program is distributed in the hope that it will be useful, but WITHOUT 015 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 016 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more 017 * details. You should have received a copy of the GNU Affero General Public 018 * License along with this program; if not, see http://www.gnu.org/licenses or 019 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 020 * Boston, MA, 02110-1301 USA, or download the license from the following URL: 021 * http://itextpdf.com/terms-of-use/ 022 * 023 * The interactive user interfaces in modified source and object code versions 024 * of this program must display Appropriate Legal Notices, as required under 025 * Section 5 of the GNU Affero General Public License. 026 * 027 * In accordance with Section 7(b) of the GNU Affero General Public License, a 028 * covered work must retain the producer line in every PDF that is created or 029 * manipulated using iText. 030 * 031 * You can be released from the requirements of the license by purchasing a 032 * commercial license. Buying such a license is mandatory as soon as you develop 033 * commercial activities involving the iText software without disclosing the 034 * source code of your own applications. These activities include: offering paid 035 * services to customers as an ASP, serving PDFs on the fly in a web 036 * application, shipping iText with a closed source product. 037 * 038 * For more information, please contact iText Software Corp. at this address: 039 * sales@itextpdf.com 040 */ 041package com.itextpdf.text.log; 042 043/** 044 * LoggerFactory can be used to set a logger. The logger should be created by 045 * implementing {@link Logger}. In the implementation users can choose how they 046 * log received messages. Added for developers. For some cases it can be handy 047 * to receive logging statements while developing applications with iText 048 * 049 * @author redlab_b 050 * 051 */ 052public class LoggerFactory { 053 054 static { 055 myself = new LoggerFactory(); 056 } 057 058 private static LoggerFactory myself; 059 /** 060 * Returns the logger set in this LoggerFactory. Defaults to {@link NoOpLogger} 061 * @param klass 062 * @return the logger. 063 */ 064 public static Logger getLogger(final Class<?> klass) { 065 return myself.logger.getLogger(klass); 066 } 067 /** 068 * Returns the logger set in this LoggerFactory. Defaults to {@link NoOpLogger} 069 * @param name 070 * @return the logger. 071 */ 072 public static Logger getLogger(final String name) { 073 return myself.logger.getLogger(name); 074 } 075 /** 076 * Returns the LoggerFactory 077 * @return singleton instance of this LoggerFactory 078 */ 079 public static LoggerFactory getInstance() { 080 return myself; 081 } 082 083 private Logger logger = new NoOpLogger(); 084 085 private LoggerFactory() { 086 } 087 088 /** 089 * Set the global logger to process logging statements with. 090 * 091 * @param logger the logger 092 */ 093 public void setLogger(final Logger logger) { 094 this.logger = logger; 095 } 096 097 /** 098 * Get the logger. 099 * 100 * @return the logger 101 */ 102 public Logger logger() { 103 return logger; 104 } 105 106 107}