001: // Jericho HTML Parser - Java based library for analysing and manipulating HTML
002: // Version 2.5
003: // Copyright (C) 2007 Martin Jericho
004: // http://jerichohtml.sourceforge.net/
005: //
006: // This library is free software; you can redistribute it and/or
007: // modify it under the terms of either one of the following licences:
008: //
009: // 1. The Eclipse Public License (EPL) version 1.0,
010: // included in this distribution in the file licence-epl-1.0.html
011: // or available at http://www.eclipse.org/legal/epl-v10.html
012: //
013: // 2. The GNU Lesser General Public License (LGPL) version 2.1 or later,
014: // included in this distribution in the file licence-lgpl-2.1.txt
015: // or available at http://www.gnu.org/licenses/lgpl.txt
016: //
017: // This library is distributed on an "AS IS" basis,
018: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
019: // See the individual licence texts for more details.
020:
021: package au.id.jericho.lib.html;
022:
023: /**
024: * Defines the interface for handling log messages.
025: * <p>
026: * It is not usually necessary for users to create implementations of this interface, as
027: * the {@link LoggerProvider} interface contains several predefined instances which provide the most commonly required <code>Logger</code> implementations.
028: * <p>
029: * By default, logging is configured automatically according to the algorithm described in the static {@link Config#LoggerProvider} property.
030: * <p>
031: * An instance of a class that implements this interface is used by calling the {@link Source#setLogger(Logger)} method on the relevant {@link Source} object.
032: * <p>
033: * Four <i><a name="LoggingLevel">logging levels</a></i> are defined in this interface.
034: * The logging level is specified only by the use of different method names, there is no class or type defining the levels.
035: * This makes the code required to wrap other logging frameworks much simpler and more efficient.
036: * <p>
037: * The four logging levels are:
038: * <ul class="SmallVerticalMargin">
039: * <li>{@link #error(String) ERROR}
040: * <li>{@link #warn(String) WARN}
041: * <li>{@link #info(String) INFO}
042: * <li>{@link #debug(String) DEBUG}
043: * </ul>
044: * <p>
045: * IMPLEMENTATION NOTE: Ideally the <code>java.util.logging.Logger</code> class could have been used as a basis for logging, even if used to define a wrapper
046: * around other logging frameworks.
047: * This would have avoided the need to define yet another logging interface, but because <code>java.util.logging.Logger</code> is implemented very poorly,
048: * it is quite tricky to extend it as a wrapper.
049: * Other logging wrapper frameworks such as <a target="_blank" href="http://www.slf4j.org/">SLF4J</a> or
050: * <a target="_blank" href="http://jakarta.apache.org/commons/logging/">Jakarta Commons Logging</a> provide good logging interfaces, but to avoid
051: * introducing dependencies it was decided to create this new interface.
052: *
053: * @see Config#LoggerProvider
054: */
055: public interface Logger {
056: /**
057: * Logs a message at the ERROR level.
058: * @param message the message to log.
059: */
060: void error(String message);
061:
062: /**
063: * Logs a message at the WARN level.
064: * @param message the message to log.
065: */
066: void warn(String message);
067:
068: /**
069: * Logs a message at the INFO level.
070: * @param message the message to log.
071: */
072: void info(String message);
073:
074: /**
075: * Logs a message at the DEBUG level.
076: * @param message the message to log.
077: */
078: void debug(String message);
079:
080: /**
081: * Indicates whether logging is enabled at the ERROR level.
082: * @return <code>true</code> if logging is enabled at the ERROR level, otherwise <code>false</code>.
083: */
084: boolean isErrorEnabled();
085:
086: /**
087: * Indicates whether logging is enabled at the WARN level.
088: * @return <code>true</code> if logging is enabled at the WARN level, otherwise <code>false</code>.
089: */
090: boolean isWarnEnabled();
091:
092: /**
093: * Indicates whether logging is enabled at the INFO level.
094: * @return <code>true</code> if logging is enabled at the INFO level, otherwise <code>false</code>.
095: */
096: boolean isInfoEnabled();
097:
098: /**
099: * Indicates whether logging is enabled at the DEBUG level.
100: * @return <code>true</code> if logging is enabled at the DEBUG level, otherwise <code>false</code>.
101: */
102: boolean isDebugEnabled();
103: }
|