Example usage for java.util.logging Logger log

List of usage examples for java.util.logging Logger log

Introduction

In this page you can find the example usage for java.util.logging Logger log.

Prototype

public void log(Level level, Supplier<String> msgSupplier) 

Source Link

Document

Log a message, which is only to be constructed if the logging level is such that the message will actually be logged.

Usage

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>/*  w w 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);
    }
}

From source file:pcgen.util.Logging.java

/**
 * Print information message if PCGen is debugging.
 *
 * @param s String information message//from ww w. j a  v a2 s.  c  om
 */
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

/**
 * Report where an issue was encountered.
 *
 * @param sourceUri the source containing the resource 
 *//*  w w  w  .j  ava  2 s. c o  m*/
public static void reportSource(final Level lvl, final URI sourceUri) {
    Logger l = getLogger();
    if (l.isLoggable(lvl)) {
        if (sourceUri != null) {
            l.log(lvl, " (Source: " + sourceUri + ')');
        } else {
            l.log(lvl, " (Source unknown)");
        }
    }
}

From source file:pcgen.util.Logging.java

/**
 * Beep and print error message if PCGen is debugging.
 *
 * @param s String error message/*from   w ww .jav a 2  s  . c o m*/
 * @param sourceURI the source containing the resource in error
 */
public static void errorPrint(final String s, final URI sourceURI) {
    if (debugMode) {
        S_TOOLKIT.beep();
    }

    Logger l = getLogger();
    if (l.isLoggable(ERROR)) {
        if (sourceURI != null) {
            l.log(ERROR, s + " (Source: " + sourceURI + " )");
        } else {
            l.log(ERROR, s);
        }
    }
}

From source file:pcgen.util.Logging.java

/**
 * Report where an issue was encountered.
 *
 * @param context the LoadContext containing the resource 
 *//*  ww  w  .ja  v a  2 s  .  c o  m*/
public static void reportSource(final Level lvl, final LoadContext context) {
    Logger l = getLogger();
    if (l.isLoggable(lvl)) {
        if (context != null && context.getSourceURI() != null) {
            l.log(lvl, " (Source: " + context.getSourceURI() + " )");
        } else {
            l.log(lvl, " (Source unknown)");
        }
    }
}

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)
 *///w  ww .  ja v a  2  s  .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

/**
 * Beep and print error message if PCGen is debugging.
 *
 * @param s String error message//w  w w  . ja  v a 2s .  c om
 * @param context the LoadContext containing the deprecated resource
 */
public static void errorPrint(final String s, final LoadContext context) {
    if (debugMode) {
        S_TOOLKIT.beep();
    }

    Logger l = getLogger();
    if (l.isLoggable(ERROR)) {
        if (context != null && context.getSourceURI() != null) {
            l.log(ERROR, s + " (Source: " + context.getSourceURI() + " )");
        } else {
            l.log(ERROR, s);
        }
    }
}

From source file:pcgen.util.Logging.java

/**
 * Beep and print error message if PCGen is debugging.
 *
 * @param s String error message/*from w  ww .j  a  va  2 s .c  om*/
 * @param context the LoadContext containing the deprecated resource 
 */
public static void deprecationPrint(final String s, final LoadContext context) {
    if (debugMode) {
        S_TOOLKIT.beep();
    }

    Logger l = getLogger();
    if (l.isLoggable(LST_WARNING) && SettingsHandler.outputDeprecationMessages()) {
        if (context != null && context.getSourceURI() != null) {
            l.log(LST_WARNING, s + " (Source: " + context.getSourceURI() + " )");
        } else {
            l.log(LST_WARNING, s);
        }
    }
}

From source file:org.openspaces.focalserver.FocalServer.java

public void shutdown() {
    Logger logger = Logger.getLogger(FocalServer.class.getName());
    logger.log(Level.INFO, "FocalServer Shutdown.");
    System.exit(0);//from ww  w  .j ava  2  s.co  m
}

From source file:com.boldust.math001.Math001Test.java

/**
 * Test of pow001 method, of class Math001.
 *///from   www .j  ava 2  s.c o m
@Test
public void testPow001() {
    System.out.println("pow001");
    Logger l = Logger.getLogger("powtest001");
    //        l.addHandler(new java.util.logging.ConsoleHandler());
    l.log(Level.SEVERE, "Powtest001");
    int base = 20;
    int exp = 5;
    BigInteger expResult = new BigInteger(Integer.valueOf(3200000).toString());
    BigInteger result1 = new BigInteger(Integer.valueOf(3200000).toString());
    BigInteger result = Math001.pow001(base, exp);
    System.out.println(expResult.equals(result));
    assertEquals(expResult, result);
    assertEquals(result1, result);
    // TODO review the generated test code and remove the default call to fail.
    //fail("The test case is a prototype.");
}