List of usage examples for java.util.logging Logger isLoggable
public boolean isLoggable(Level level)
From source file:org.usrz.libs.logging.LevelErrorTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasNoLastEvent("at Finest level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasNoLastEvent("at Finer level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasNoLastEvent("at Fine level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasNoLastEvent("at Config level"); assertFalse(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasNoLastEvent("at Info level"); assertFalse(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasNoLastEvent("at Warning level"); assertFalse(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:org.usrz.libs.logging.LevelInfoTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasNoLastEvent("at Finest level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasNoLastEvent("at Finer level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasNoLastEvent("at Fine level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasLastEvent("at Config level"); assertTrue(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasLastEvent("at Info level"); assertTrue(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasLastEvent("at Warning level"); assertTrue(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:org.usrz.libs.logging.LevelTraceTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasLastEvent("at Finest level"); assertTrue(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasLastEvent("at Finer level"); assertTrue(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasLastEvent("at Fine level"); assertTrue(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasLastEvent("at Config level"); assertTrue(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasLastEvent("at Info level"); assertTrue(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasLastEvent("at Warning level"); assertTrue(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:org.usrz.libs.logging.LevelWarningTest.java
@Test public void testJavaLogging() { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getName()); logger.finest("Foobar FINEST"); AppenderForTests.hasNoLastEvent("at Finest level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINEST)); logger.finer("Foobar FINER"); AppenderForTests.hasNoLastEvent("at Finer level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINER)); logger.fine("Foobar FINE"); AppenderForTests.hasNoLastEvent("at Fine level"); assertFalse(logger.isLoggable(java.util.logging.Level.FINE)); logger.config("Foobar CONFIG"); AppenderForTests.hasNoLastEvent("at Config level"); assertFalse(logger.isLoggable(java.util.logging.Level.CONFIG)); logger.info("Foobar INFO"); AppenderForTests.hasNoLastEvent("at Info level"); assertFalse(logger.isLoggable(java.util.logging.Level.INFO)); logger.warning("Foobar WARNING"); AppenderForTests.hasLastEvent("at Warning level"); assertTrue(logger.isLoggable(java.util.logging.Level.WARNING)); logger.severe("Foobar SEVERE"); AppenderForTests.hasLastEvent("at Severe level"); assertTrue(logger.isLoggable(java.util.logging.Level.SEVERE)); }
From source file:pcgen.util.Logging.java
/** * Check if the level of logs would be output for the caller. This can * be used to prevent building logging output if it will not be used. * @param level The logging level to be checked. * @return true if the level would be output, false if not. *//*from w w w . j a v a2 s . c om*/ public static boolean isLoggable(Level level) { Logger l = getLogger(); return l != null && l.isLoggable(level); }
From source file:pcgen.util.Logging.java
/** * Print information message if PCGen is debugging. * * @param s String information message//from w w w . j a va 2 s.c o m */ public static void debugPrint(final String s) { Logger l = getLogger(); if (l != null && l.isLoggable(DEBUG)) { l.log(DEBUG, s); } }
From source file:pcgen.util.Logging.java
/** * Print information message if PCGen is debugging. * * @param param1 String information message (usually variable) * @param param2 Object information message (usually value) */// w w w.j a va 2s . com public static void debugPrint(final String param1, Object param2) { Logger l = getLogger(); if (l.isLoggable(DEBUG)) { l.log(DEBUG, param1 + param2); } }
From source file:pcgen.util.Logging.java
/** * Print localised information message if PCGen is debugging. * * @param message String information message (usually variable) * @param params Object information message (usually value) *///from ww w . ja va 2s .co m public static void debugPrintLocalised(final String message, Object... params) { Logger l = getLogger(); if (l.isLoggable(DEBUG)) { String msg = LanguageBundle.getFormattedString(message, params); l.log(DEBUG, msg); } }
From source file:pcgen.util.Logging.java
/** * Print the message. Currently quietly discards the Throwable. * * @param s String error message// w w w.j av a 2 s . co m * @param thr Throwable stack frame */ public static void debugPrint(final String s, final Throwable thr) { debugPrint(s); Logger l = getLogger(); if (l != null && l.isLoggable(DEBUG)) { thr.printStackTrace(System.err); } }
From source file:pcgen.util.Logging.java
/** * Print a localized error message including parameter substitution. The * method will issue a beep if the application is running in Debug mode. * <p>//from ww w. j ava 2s . c om * This method accepts a variable number of parameters and will replace * {@code {argno}} in the string with each passed paracter in turn. * * @param aKey * A key for the localized string in the language bundle * @param varargs * Variable number of parameters to substitute into the string */ public static void errorPrintLocalised(final String aKey, Object... varargs) { if (debugMode) { S_TOOLKIT.beep(); } final String msg = LanguageBundle.getFormattedString(aKey, varargs); Logger l = getLogger(); if (l.isLoggable(ERROR)) { l.log(ERROR, msg); } }