001package org.apache.maven.doxia.logging;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022/**
023 * This interface supplies the API for providing feedback to the user from
024 * a Parser or Sink, using standard <code>Doxia</code> channels.
025 * <br>
026 * There should be no big surprises here, although you may notice that the methods accept
027 * <code>java.lang.CharSequence</code> rather than <code>java.lang.String</code>. This is provided mainly as a
028 * convenience, to enable developers to pass things like <code>java.lang.StringBuilder</code> directly into the logger,
029 * rather than formatting first by calling <code>toString()</code>.
030 * <br>
031 * Based on <code>org.apache.maven.plugin.logging.Log</code>.
032 *
033 * @author jdcasey
034 * @author ltheussl
035 * @since 1.1
036 */
037public interface Log
038{
039    /** Typecode for debugging messages. */
040    int LEVEL_DEBUG = 0;
041
042    /** Typecode for informational messages. */
043    int LEVEL_INFO = 1;
044
045    /** Typecode for warning messages. */
046    int LEVEL_WARN = 2;
047
048    /** Typecode for error messages. */
049    int LEVEL_ERROR = 3;
050
051    /** Typecode for fatal error messages. */
052    int LEVEL_FATAL = 4;
053
054    /** Typecode for disabled log levels. */
055    int LEVEL_DISABLED = 5;
056
057    /**
058     * Set the current log level.
059     *
060     * @param level the log level to set.
061     */
062    void setLogLevel( int level );
063
064    /**
065     * <p>isDebugEnabled.</p>
066     *
067     * @return true if the <b>debug</b> error level is enabled.
068     */
069    boolean isDebugEnabled();
070
071    /**
072     * Send a message to the user in the <b>debug</b> error level.
073     *
074     * @param content the message to log.
075     */
076    void debug( CharSequence content );
077
078    /**
079     * Send a message (and accompanying exception) to the user in the <b>debug</b> error level.
080     * <br>
081     * The error's stacktrace will be output when this error level is enabled.
082     *
083     * @param content the message to log.
084     * @param error the error to log.
085     */
086    void debug( CharSequence content, Throwable error );
087
088    /**
089     * Send an exception to the user in the <b>debug</b> error level.
090     * <br>
091     * The stack trace for this exception will be output when this error level is enabled.
092     *
093     * @param error the error to log.
094     */
095    void debug( Throwable error );
096
097    /**
098     * <p>isInfoEnabled.</p>
099     *
100     * @return true if the <b>info</b> error level is enabled.
101     */
102    boolean isInfoEnabled();
103
104    /**
105     * Send a message to the user in the <b>info</b> error level.
106     *
107     * @param content the message to log.
108     */
109    void info( CharSequence content );
110
111    /**
112     * Send a message (and accompanying exception) to the user in the <b>info</b> error level.
113     * <br>
114     * The error's stacktrace will be output when this error level is enabled.
115     *
116     * @param content the message to log.
117     * @param error the error to log.
118     */
119    void info( CharSequence content, Throwable error );
120
121    /**
122     * Send an exception to the user in the <b>info</b> error level.
123     * <br>
124     * The stack trace for this exception will be output when this error level is enabled.
125     *
126     * @param error the error to log.
127     */
128    void info( Throwable error );
129
130    /**
131     * <p>isWarnEnabled.</p>
132     *
133     * @return true if the <b>warn</b> error level is enabled.
134     */
135    boolean isWarnEnabled();
136
137    /**
138     * Send a message to the user in the <b>warn</b> error level.
139     *
140     * @param content the message to log.
141     */
142    void warn( CharSequence content );
143
144    /**
145     * Send a message (and accompanying exception) to the user in the <b>warn</b> error level.
146     * <br>
147     * The error's stacktrace will be output when this error level is enabled.
148     *
149     * @param content the message to log.
150     * @param error the error to log.
151     */
152    void warn( CharSequence content, Throwable error );
153
154    /**
155     * Send an exception to the user in the <b>warn</b> error level.
156     * <br>
157     * The stack trace for this exception will be output when this error level is enabled.
158     *
159     * @param error the error to log.
160     */
161    void warn( Throwable error );
162
163    /**
164     * <p>isErrorEnabled.</p>
165     *
166     * @return true if the <b>error</b> error level is enabled.
167     */
168    boolean isErrorEnabled();
169
170    /**
171     * Send a message to the user in the <b>error</b> error level.
172     *
173     * @param content the message to log.
174     */
175    void error( CharSequence content );
176
177    /**
178     * Send a message (and accompanying exception) to the user in the <b>error</b> error level.
179     * <br>
180     * The error's stacktrace will be output when this error level is enabled.
181     *
182     * @param content the message to log.
183     * @param error the error to log.
184     */
185    void error( CharSequence content, Throwable error );
186
187    /**
188     * Send an exception to the user in the <b>error</b> error level.
189     * <br>
190     * The stack trace for this exception will be output when this error level is enabled.
191     *
192     * @param error the error to log.
193     */
194    void error( Throwable error );
195}