1 package org.apache.ojb.broker.util.logging; 2 3 /* Copyright 2002-2005 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 import org.apache.ojb.broker.util.configuration.Configurable; 19 import org.apache.ojb.broker.util.configuration.Configuration; 20 import org.apache.ojb.broker.util.configuration.ConfigurationException; 21 22 import java.io.Serializable; 23 24 25 /** 26 * this interface defines the behaviour of a logging mechanism. 27 * This API corresponds closely to the LOG4J Category Api. 28 * By using this interface OJB remains free from Logger-Implementation 29 * specific code. 30 */ 31 public interface Logger extends Serializable, Configurable 32 { 33 static final long serialVersionUID = 1177329037874407180L; /* 34 * OJB loglevel constants. they corespond directly to LOG4J LogLevels. 35 */ 36 public final static int DEBUG = 1; 37 public final static int INFO = 2; 38 public final static int WARN = 3; 39 public final static int ERROR = 4; 40 public final static int FATAL = 5; 41 42 43 /** 44 * generate a message for loglevel DEBUG 45 * @param pObject the message Object 46 */ 47 public void debug(Object pObject); 48 49 /** 50 * generate a message for loglevel INFO 51 * @param pObject the message Object 52 */ 53 public void info(Object pObject); 54 55 /** 56 * generate a message for loglevel WARN 57 * @param pObject the message Object 58 */ 59 public void warn(Object pObject); 60 61 /** 62 * generate a message for loglevel ERROR 63 * @param pObject the message Object 64 */ 65 public void error(Object pObject); 66 67 /** 68 * generate a message for loglevel FATAL 69 * @param pObject the message Object 70 */ 71 public void fatal(Object pObject); 72 73 public void debug(Object message, Throwable obj); 74 public void info(Object message, Throwable obj); 75 public void warn(Object message, Throwable obj); 76 public void error(Object message, Throwable obj); 77 public void fatal(Object message, Throwable obj); 78 79 public boolean isEnabledFor(int priority); 80 public boolean isDebugEnabled(); 81 82 /** 83 * returns the name of the logger isntance 84 */ 85 public String getName(); 86 87 /** 88 * Exception safe log method. 89 * This method can be used to prevent any exception thrown by obj.toString() implementations. 90 * Log level used : DEBUG 91 * @deprecated The normal logging methods should always be safe with regard to exceptions 92 * that are thrown while accessing the arguments. 93 */ 94 public void safeDebug(String message, Object obj); 95 96 /** 97 * Exception safe log method. 98 * This method can be used to prevent any exception thrown by obj.toString() implementations. 99 * Log level used : DEBUG 100 * @deprecated The normal logging methods should always be safe with regard to exceptions 101 * that are thrown while accessing the arguments. 102 */ 103 public void safeDebug(String message, Object obj, Throwable t); 104 105 /** 106 * Exception safe log method. 107 * This method can be used to prevent any exception thrown by obj.toString() implementations. 108 * Log level used : INFO 109 * @deprecated The normal logging methods should always be safe with regard to exceptions 110 * that are thrown while accessing the arguments. 111 */ 112 public void safeInfo(String message, Object obj); 113 114 /** 115 * Exception safe log method. 116 * This method can be used to prevent any exception thrown by obj.toString() implementations. 117 * Log level used : INFO 118 * @deprecated The normal logging methods should always be safe with regard to exceptions 119 * that are thrown while accessing the arguments. 120 */ 121 public void safeInfo(String message, Object obj, Throwable t); 122 123 /** 124 * Exception safe log method. 125 * This method can be used to prevent any exception thrown by obj.toString() implementations. 126 * Log level used : WARN 127 * @deprecated The normal logging methods should always be safe with regard to exceptions 128 * that are thrown while accessing the arguments. 129 */ 130 public void safeWarn(String message, Object obj); 131 132 /** 133 * Exception safe log method. 134 * This method can be used to prevent any exception thrown by obj.toString() implementations. 135 * Log level used : WARN 136 * @deprecated The normal logging methods should always be safe with regard to exceptions 137 * that are thrown while accessing the arguments. 138 */ 139 public void safeWarn(String message, Object obj, Throwable t); 140 141 /** 142 * Exception safe log method. 143 * This method can be used to prevent any exception thrown by obj.toString() implementations. 144 * Log level used : ERROR 145 * @deprecated The normal logging methods should always be safe with regard to exceptions 146 * that are thrown while accessing the arguments. 147 */ 148 public void safeError(String message, Object obj); 149 150 /** 151 * Exception safe log method. 152 * This method can be used to prevent any exception thrown by obj.toString() implementations. 153 * Log level used : ERROR 154 * @deprecated The normal logging methods should always be safe with regard to exceptions 155 * that are thrown while accessing the arguments. 156 */ 157 public void safeError(String message, Object obj, Throwable t); 158 159 /** 160 * Exception safe log method. 161 * This method can be used to prevent any exception thrown by obj.toString() implementations. 162 * Log level used : FATAL 163 * @deprecated The normal logging methods should always be safe with regard to exceptions 164 * that are thrown while accessing the arguments. 165 */ 166 public void safeFatal(String message, Object obj); 167 168 /** 169 * Exception safe log method. 170 * This method can be used to prevent any exception thrown by obj.toString() implementations. 171 * Log level used : FATAL 172 * @deprecated The normal logging methods should always be safe with regard to exceptions 173 * that are thrown while accessing the arguments. 174 */ 175 public void safeFatal(String message, Object obj, Throwable t); 176 177 /** 178 * Configure this logging. Note that the config object will be an instance 179 * of {@link LoggingConfiguration}. 180 * 181 * @param config The {@link LoggingConfiguration} object 182 * @throws ConfigurationException 183 */ 184 void configure(Configuration config) throws ConfigurationException; 185 }