1 // Jericho HTML Parser - Java based library for analysing and manipulating HTML 2 // Version 3.2 3 // Copyright (C) 2004-2009 Martin Jericho 4 // http://jericho.htmlparser.net/ 5 // 6 // This library is free software; you can redistribute it and/or 7 // modify it under the terms of either one of the following licences: 8 // 9 // 1. The Eclipse Public License (EPL) version 1.0, 10 // included in this distribution in the file licence-epl-1.0.html 11 // or available at http://www.eclipse.org/legal/epl-v10.html 12 // 13 // 2. The GNU Lesser General Public License (LGPL) version 2.1 or later, 14 // included in this distribution in the file licence-lgpl-2.1.txt 15 // or available at http://www.gnu.org/licenses/lgpl.txt 16 // 17 // This library is distributed on an "AS IS" basis, 18 // WITHOUT WARRANTY OF ANY KIND, either express or implied. 19 // See the individual licence texts for more details. 20 21 package net.htmlparser.jericho; 22 23 /** 24 * Defines the interface for handling log messages. 25 * <p> 26 * It is not usually necessary for users to create implementations of this interface, as 27 * the {@link LoggerProvider} interface contains several predefined instances which provide the most commonly required <code>Logger</code> implementations. 28 * <p> 29 * By default, logging is configured automatically according to the algorithm described in the static {@link Config#LoggerProvider} property. 30 * <p> 31 * 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. 32 * <p> 33 * Four <i><a name="LoggingLevel">logging levels</a></i> are defined in this interface. 34 * The logging level is specified only by the use of different method names, there is no class or type defining the levels. 35 * This makes the code required to wrap other logging frameworks much simpler and more efficient. 36 * <p> 37 * The four logging levels are: 38 * <ul class="SmallVerticalMargin"> 39 * <li>{@link #error(String) ERROR} 40 * <li>{@link #warn(String) WARN} 41 * <li>{@link #info(String) INFO} 42 * <li>{@link #debug(String) DEBUG} 43 * </ul> 44 * <p> 45 * 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 46 * around other logging frameworks. 47 * This would have avoided the need to define yet another logging interface, but because <code>java.util.logging.Logger</code> is implemented very poorly, 48 * it is quite tricky to extend it as a wrapper. 49 * Other logging wrapper frameworks such as <a target="_blank" href="http://www.slf4j.org/">SLF4J</a> or 50 * <a target="_blank" href="http://jakarta.apache.org/commons/logging/">Jakarta Commons Logging</a> provide good logging interfaces, but to avoid 51 * introducing dependencies it was decided to create this new interface. 52 * 53 * @see Config#LoggerProvider 54 */ 55 public interface Logger { 56 /** 57 * Logs a message at the ERROR level. 58 * @param message the message to log. 59 */ error(String message)60 void error(String message); 61 62 /** 63 * Logs a message at the WARN level. 64 * @param message the message to log. 65 */ warn(String message)66 void warn(String message); 67 68 /** 69 * Logs a message at the INFO level. 70 * @param message the message to log. 71 */ info(String message)72 void info(String message); 73 74 /** 75 * Logs a message at the DEBUG level. 76 * @param message the message to log. 77 */ debug(String message)78 void debug(String message); 79 80 /** 81 * Indicates whether logging is enabled at the ERROR level. 82 * @return <code>true</code> if logging is enabled at the ERROR level, otherwise <code>false</code>. 83 */ isErrorEnabled()84 boolean isErrorEnabled(); 85 86 /** 87 * Indicates whether logging is enabled at the WARN level. 88 * @return <code>true</code> if logging is enabled at the WARN level, otherwise <code>false</code>. 89 */ isWarnEnabled()90 boolean isWarnEnabled(); 91 92 /** 93 * Indicates whether logging is enabled at the INFO level. 94 * @return <code>true</code> if logging is enabled at the INFO level, otherwise <code>false</code>. 95 */ isInfoEnabled()96 boolean isInfoEnabled(); 97 98 /** 99 * 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 */ isDebugEnabled()102 boolean isDebugEnabled(); 103 }