Java Code Examples for java.util.logging.Logger.finest()

The following are Jave code examples for showing how to use finest() of the java.util.logging.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: EarlyHandlerTest.java   Source Code and License Vote up 6 votes
public void testEarlyPublish() throws Exception {
    EarlyHandler eh = Lookup.getDefault().lookup(EarlyHandler.class);
    Logger allLogger = Logger.getLogger("org.myapplication.ui.test_early"); // Copied Installer.UI_LOGGER_NAME, not to initialize Installer class.
    allLogger.setLevel(Level.ALL);
    allLogger.addHandler(eh);
    
    allLogger.fine("Test Message 1");
    allLogger.info("Test Message 2");
    allLogger.finest("Test Message 3");
    
    Installer installer = Installer.findObject(Installer.class, true);
    installer.restored();
    assertEquals("EarlyHandler turned off", Level.OFF, eh.getLevel());
    
    allLogger.finer("Test Message 4");
    
    List<LogRecord> logs = InstallerTest.getLogs();
    assertEquals("Number of messages logged: ", 4, logs.size());
    for (int i = 0; i < logs.size(); i++) {
        assertEquals("Test Message "+(i+1), logs.get(i).getMessage());
    }
}
 
Example 2
Project: jdk8u-jdk   File: TestIsLoggable.java   Source Code and License Vote up 6 votes
public void loglevel(Level l, Logger logger, String message) {
    LogTest test = LogTest.valueOf("LEV_"+l.getName());
    switch(test) {
        case LEV_SEVERE:
            logger.severe(message);
            break;
        case LEV_WARNING:
            logger.warning(message);
            break;
        case LEV_INFO:
            logger.info(message);
            break;
        case LEV_CONFIG:
            logger.config(message);
            break;
        case LEV_FINE:
            logger.fine(message);
            break;
        case LEV_FINER:
            logger.finer(message);
            break;
        case LEV_FINEST:
            logger.finest(message);
            break;
    }
}
 
Example 3
Project: openjdk-jdk10   File: TestIsLoggable.java   Source Code and License Vote up 6 votes
public void loglevel(Level l, Logger logger, String message) {
    LogTest test = LogTest.valueOf("LEV_"+l.getName());
    switch(test) {
        case LEV_SEVERE:
            logger.severe(message);
            break;
        case LEV_WARNING:
            logger.warning(message);
            break;
        case LEV_INFO:
            logger.info(message);
            break;
        case LEV_CONFIG:
            logger.config(message);
            break;
        case LEV_FINE:
            logger.fine(message);
            break;
        case LEV_FINER:
            logger.finer(message);
            break;
        case LEV_FINEST:
            logger.finest(message);
            break;
    }
}
 
Example 4
Project: classinjector   File: InjectorClassLoader.java   Source Code and License Vote up 5 votes
private Class<?> injectClass(String name) {
    if (name.startsWith(MY_PACKAGE)) {
        return null;
    }
    Set<String> classes = findingClasses;
    if (classes.contains(name)) {
        throw new IllegalStateException(name + " is recursively loaded");
    }
    ClassFile f;
    try {
        f = source.getClassFile(name);
    } catch (IOException e) {
        throw new IOError(e);
    }
    if (f == null) {
        return null;
    }
    classes.add(name);
    try {
        Class<?> c = f.toClass(injectionTarget);
        Logger logger = Loggers.get();
        if (logger.isLoggable(Level.FINEST)) {
            String hash = Integer.toHexString(System.identityHashCode(injectionTarget));
            String target = injectionTarget.getClass().getName() + '@' + hash;
            logger.finest("The class " + c.getName() + " was injected into " + target);
        }
        return c;
    } finally {
        classes.remove(name);
    }
}
 
Example 5
Project: alvisnlp   File: AbstractAlvisNLP.java   Source Code and License Vote up 5 votes
private void error(Logger logger, Exception e, String msg) {
  	logger.severe(msg);
  	if (logger.isLoggable(Level.FINEST)) {
  		for (Throwable t = e; t != null; t = t.getCause()) {
  			logger.finest(t.getClass().getCanonicalName());
  			for (StackTraceElement ste : t.getStackTrace())
  				logger.finest("    " + ste);
  		}
  	}
else
	logger.info("use -verbose option to get debug info");
  	exitCode = 1;
  }
 
Example 6
Project: freecol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @param range The exclusive maximum integer to return.
 * @param n The number of randoms.
 * @return A vector of pseudo-random integers r, 0 &le; r &lt; range.
 */
public static int[] randomInts(Logger logger, String logMe, Random random,
                               int range, int n) {
    int[] ret = new int[n];
    for (int i = 0; i < n; i++) ret[i] = random.nextInt(range);
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        StringBuilder sb = new StringBuilder(64);
        sb.append(logMe).append(" random(").append(range).append(") = [");
        for (int i = 0; i < n; i++) sb.append(' ').append(ret[i]);
        sb.append(" ]");
        logger.finest(sb.toString());
    }
    return ret;
}
 
Example 7
Project: freecol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @return A pseudo-random double r, 0 &le; r &lt; 1.0.
 */
public static float randomFloat(Logger logger, String logMe,
                                Random random) {
    float ret = random.nextFloat();
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " random(1.0f) = " + ret);
    }
    return ret;
}
 
Example 8
Project: freecol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @return A pseudo-random double r, 0 &le; r &lt; 1.0.
 */
public static double randomDouble(Logger logger, String logMe,
                                  Random random) {
    double ret = random.nextDouble();
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " random(1.0) = " + ret);
    }
    return ret;
}
 
Example 9
Project: freecol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Shuffle a list.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param list The list.
 * @param random A random number source.
 */
public static void randomShuffle(Logger logger, String logMe,
                                 List<?> list, Random random) {
    if (list.size() <= 1 || random == null) return;
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " shuffle.");
    }
    Collections.shuffle(list, random);
}
 
Example 10
Project: FreeCol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @param range The exclusive maximum integer to return.
 * @param n The number of randoms.
 * @return A vector of pseudo-random integers r, 0 &le; r &lt; range.
 */
public static int[] randomInts(Logger logger, String logMe, Random random,
                               int range, int n) {
    int[] ret = new int[n];
    for (int i = 0; i < n; i++) ret[i] = random.nextInt(range);
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        StringBuilder sb = new StringBuilder(64);
        sb.append(logMe).append(" random(").append(range).append(") = [");
        for (int i = 0; i < n; i++) sb.append(' ').append(ret[i]);
        sb.append(" ]");
        logger.finest(sb.toString());
    }
    return ret;
}
 
Example 11
Project: FreeCol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @return A pseudo-random double r, 0 &le; r &lt; 1.0.
 */
public static float randomFloat(Logger logger, String logMe,
                                Random random) {
    float ret = random.nextFloat();
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " random(1.0f) = " + ret);
    }
    return ret;
}
 
Example 12
Project: FreeCol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @return A pseudo-random double r, 0 &le; r &lt; 1.0.
 */
public static double randomDouble(Logger logger, String logMe,
                                  Random random) {
    double ret = random.nextDouble();
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " random(1.0) = " + ret);
    }
    return ret;
}
 
Example 13
Project: FreeCol   File: RandomUtils.java   Source Code and License Vote up 5 votes
/**
 * Shuffle a list.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param list The list.
 * @param random A random number source.
 */
public static void randomShuffle(Logger logger, String logMe,
                                 List<?> list, Random random) {
    if (list.size() <= 1 || random == null) return;
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " shuffle.");
    }
    Collections.shuffle(list, random);
}
 
Example 14
Project: openjdk-jdk10   File: TestInferCaller.java   Source Code and License Vote up 4 votes
public void test1(Logger logger) {
    System.out.println("test1: " + loggerName(logger));

    AtomicInteger count = new AtomicInteger();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    logger.setLevel(Level.ALL);
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");

    logger.severe("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    LogEvent event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.warning("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.info("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.config("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.fine("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.finer("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.finest("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());
}
 
Example 15
Project: openjdk-jdk10   File: TestInferCaller.java   Source Code and License Vote up 4 votes
public void test4(Logger logger) {
    System.out.println("test4: " + loggerName(logger));
    AtomicInteger count = new AtomicInteger();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    logger.setLevel(Level.ALL);
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");

    logger.severe(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    LogEvent event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.warning(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.info(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.config(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.fine(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.finer(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.finest(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
}
 
Example 16
Project: freecol   File: RandomUtils.java   Source Code and License Vote up 3 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @param range The exclusive maximum integer to return.
 * @return A pseudo-random integer r, 0 &le; r &lt; range.
 */
public static int randomInt(Logger logger, String logMe, Random random,
                            int range) {
    int ret = random.nextInt(range);
    if (logger != null) {
        logger.finest(logMe + " random(" + range + ") = " + ret);
    }
    return ret;
}
 
Example 17
Project: FreeCol   File: RandomUtils.java   Source Code and License Vote up 3 votes
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @param range The exclusive maximum integer to return.
 * @return A pseudo-random integer r, 0 &le; r &lt; range.
 */
public static int randomInt(Logger logger, String logMe, Random random,
                            int range) {
    int ret = random.nextInt(range);
    if (logger != null) {
        logger.finest(logMe + " random(" + range + ") = " + ret);
    }
    return ret;
}