package org.jlf.log;
/**
* AppLog
wraps the Log class to do application-general
* logging. It provides a singleton accessor, along with lots of
* handy class method {static} accessors.
*
* AppLog
should be your general application log to write out events
* of a non-specific nature. You can create additional special-purpose
* logs (for example, DbLog to log database events) by copying
* this class and creating your own handy class method accessors.
* * @author Todd Lauinger * @version $Revision: 1.1.1.1 $ * * @see org.jlf.log.Log * */ public class AppLog { /** * Provides the class variable for the Singleton pattern, * to keep track of the one and only instance of this class. */ protected static Log singleton = new MultiThreadLog("org.jlf.log.AppLog"); /** * Protect the default constructor, this class uses a Singleton * pattern. If you need to access the Singleton instance of * the class, DON'T make this public, instead use the getInstance() * method! */ protected AppLog() { } /** * Returns the singleton instance of this class. */ public static Log getInstance() { return singleton; } /** * Logs a text string at the logging level specified. * * This method is used when your code needs to parameterize * the logging level. Otherwise you probably should use the * err(), warning(), info(), detail(), or trace() methods below, * they will be less verbose in your code. */ public static void logString(String logString, int errorLevel) { // Dispatch the call to the instance side singleton.logString(logString, errorLevel); } /** * Logs a text string at CRITICAL_ERROR_LEVEL * * This method provides the implementation for a quick accessor * to log a critical error, * replacing typical calls to System.err.println(). */ public static void criticalError(String logString) { logString(logString, Log.CRITICAL_ERROR_LEVEL); } /** * Logs a text string at ERROR_LEVEL * * This method provides the implementation for a quick accessor * to log a critical error, * replacing typical calls to System.err.println(). */ public static void error(String logString) { logString(logString, Log.ERROR_LEVEL); } /** * Logs a text string at WARNING_LEVEL */ public static void warning(String logString) { logString(logString, Log.WARNING_LEVEL); } /** * Logs a text string at INFO_LEVEL */ public static void info(String logString) { logString(logString, Log.INFO_LEVEL); } /** * Logs a text string at DETAIL_LEVEL */ public static void detail(String logString) { logString(logString, Log.DETAIL_LEVEL); } /** * Logs a text string at TRACE_LEVEL */ public static void trace(String logString) { logString(logString, Log.TRACE_LEVEL); } /** * Passthrough method to quick check if you should * bother constructing a log message to log at * a particular logging level. */ public static boolean isLoggingEnabledFor(int loggingLevel) { return singleton.isLoggingEnabledFor(loggingLevel); } }