001    package org.apache.ojb.broker.util.logging;
002    
003    /* Copyright 2002-2005 The Apache Software Foundation
004     *
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    import org.apache.ojb.broker.util.configuration.Configurable;
019    import org.apache.ojb.broker.util.configuration.Configuration;
020    import org.apache.ojb.broker.util.configuration.ConfigurationException;
021    
022    import java.io.Serializable;
023    
024    
025    /**
026     * this interface defines the behaviour of a logging mechanism.
027     * This API corresponds closely to the LOG4J Category Api.
028     * By using this interface OJB remains free from Logger-Implementation
029     * specific code.
030     */
031    public interface Logger extends Serializable, Configurable
032    {
033            static final long serialVersionUID = 1177329037874407180L;    /*
034         * OJB loglevel constants. they corespond directly to LOG4J LogLevels.
035         */
036        public final static int DEBUG = 1;
037        public final static int INFO = 2;
038        public final static int WARN = 3;
039        public final static int ERROR = 4;
040        public final static int FATAL = 5;
041    
042    
043        /**
044         * generate a message for loglevel DEBUG
045         * @param pObject the message Object
046         */
047        public void debug(Object pObject);
048    
049        /**
050         * generate a message for loglevel INFO
051         * @param pObject the message Object
052         */
053        public void info(Object pObject);
054    
055        /**
056         * generate a message for loglevel WARN
057         * @param pObject the message Object
058         */
059        public void warn(Object pObject);
060    
061        /**
062         * generate a message for loglevel ERROR
063         * @param pObject the message Object
064         */
065        public void error(Object pObject);
066    
067        /**
068         * generate a message for loglevel FATAL
069         * @param pObject the message Object
070         */
071        public void fatal(Object pObject);
072    
073        public void debug(Object message, Throwable obj);
074        public void info(Object message, Throwable obj);
075        public void warn(Object message, Throwable obj);
076        public void error(Object message, Throwable obj);
077        public void fatal(Object message, Throwable obj);
078    
079        public boolean isEnabledFor(int priority);
080        public boolean isDebugEnabled();
081    
082        /**
083         * returns the name of the logger isntance
084         */
085        public String getName();
086    
087        /**
088         * Exception safe log method.
089         * This method can be used to prevent any exception thrown by obj.toString() implementations.
090         * Log level used : DEBUG
091         * @deprecated The normal logging methods should always be safe with regard to exceptions
092         *             that are thrown while accessing the arguments. 
093         */
094        public void safeDebug(String message, Object obj);
095    
096        /**
097         * Exception safe log method.
098         * This method can be used to prevent any exception thrown by obj.toString() implementations.
099         * 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    }