001package 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. 002 003import java.util.*; 004import java.util.logging.*; 005import votorola.g.lang.*; 006 007 008/** Logger utilities. 009 */ 010public @ThreadSafe final class LoggerX 011{ 012 013 private LoggerX() {} 014 015 016 017 public static final Level OFF = Level.OFF; 018 public static final Level SEVERE = Level.SEVERE; 019 public static final Level WARNING = Level.WARNING; 020 public static final Level INFO = Level.INFO; 021 public static final Level CONFIG = Level.CONFIG; 022 public static final Level FINE = Level.FINE; 023 public static final Level FINER = Level.FINER; 024 public static final Level FINEST = Level.FINEST; 025 public static final Level ALL = Level.ALL; 026 027 028 029 /** Looks up the standard logger for a class. 030 */ 031 public static Logger i( final Class<?> cl ) { return Logger.getLogger( cl.getName() ); } 032 033 034 035 /** Looks up the standard logger for a class name. 036 */ 037 public static Logger i( final String className ) { return Logger.getLogger( className ); } 038 039 040 041 /** Logs a test message at the specified level. 042 */ 043 public static void test( final Logger logger, final Level level ) 044 { 045 logger.log( level, "test message at level " + level.toString() ); 046 } 047 048 049 050 /** Logs test messages at all levels. 051 */ 052 public static void test( final Logger logger ) 053 { 054 logger.log( OFF, "testing SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST and ALL..." ); 055 logger.severe( "this is SEVERE" ); 056 logger.warning( "this is a WARNING" ); 057 logger.info( "this is INFO" ); 058 logger.config( "this is CONFIG" ); 059 logger.fine( "this is FINE" ); 060 logger.finer( "this is FINER" ); 061 logger.finest( "this is FINEST :)" ); 062 logger.log( ALL, "this is ALL" ); // rarely logged 063 } 064 065 066 067}