package votorola.g.logging; // Copyright 2004-2006, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import java.util.*; import java.util.logging.*; import votorola.g.lang.*; /** Logger utilities. */ public @ThreadSafe final class LoggerX { private LoggerX() {} public static final Level OFF = Level.OFF; public static final Level SEVERE = Level.SEVERE; public static final Level WARNING = Level.WARNING; public static final Level INFO = Level.INFO; public static final Level CONFIG = Level.CONFIG; public static final Level FINE = Level.FINE; public static final Level FINER = Level.FINER; public static final Level FINEST = Level.FINEST; public static final Level ALL = Level.ALL; /** Looks up the standard logger for a class. */ public static Logger i( final Class cl ) { return Logger.getLogger( cl.getName() ); } /** Looks up the standard logger for a class name. */ public static Logger i( final String className ) { return Logger.getLogger( className ); } /** Logs a test message at the specified level. */ public static void test( final Logger logger, final Level level ) { logger.log( level, "test message at level " + level.toString() ); } /** Logs test messages at all levels. */ public static void test( final Logger logger ) { logger.log( OFF, "testing SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST and ALL..." ); logger.severe( "this is SEVERE" ); logger.warning( "this is a WARNING" ); logger.info( "this is INFO" ); logger.config( "this is CONFIG" ); logger.fine( "this is FINE" ); logger.finer( "this is FINER" ); logger.finest( "this is FINEST :)" ); logger.log( ALL, "this is ALL" ); // rarely logged } }