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

The following examples show how to use java.util.logging.Logger#finest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestIsLoggable.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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 2
Source File: TestIsLoggable.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: LogLevelTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
    public void testLogLevelInAppLogLineMatchesActualLogLevelUsedWhenLogging() {
        Logger log = Logger.getLogger(LogLevelTest.class.getName());
        log.finest("finest_testLogLevelMatches");
        log.finer("finer_testLogLevelMatches");
        log.fine("fine_testLogLevelMatches");
        log.config("config_testLogLevelMatches");
        log.info("info_testLogLevelMatches");
        log.warning("warning_testLogLevelMatches");
        log.severe("severe_testLogLevelMatches");
        flush(log);

        assertLogContains("finest_testLogLevelMatches", LogService.LogLevel.DEBUG);
        assertLogContains("finer_testLogLevelMatches", LogService.LogLevel.DEBUG);
        assertLogContains("fine_testLogLevelMatches", LogService.LogLevel.DEBUG);
        assertLogContains("config_testLogLevelMatches", LogService.LogLevel.DEBUG);

        // we can't test the following on dev appserver, because it returns incorrect logLevels
        // more info at http://code.google.com/p/googleappengine/issues/detail?id=8651
        //TODO:Renable after project compiles and runs.
//        assertLogContains("info_testLogLevelMatches", LogService.LogLevel.INFO);
//        assertLogContains("warning_testLogLevelMatches", LogService.LogLevel.WARN);
//        assertLogContains("severe_testLogLevelMatches", LogService.LogLevel.ERROR);
    }
 
Example 4
Source File: TestIsLoggable.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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 5
Source File: TestIsLoggable.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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 6
Source File: TestIsLoggable.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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 7
Source File: TestIsLoggable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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 8
Source File: EarlyHandlerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 9
Source File: TestIsLoggable.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 10
Source File: TestIsLoggable.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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 11
Source File: TestIsLoggable.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 12
Source File: DockerHandlerWithContainerTest.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void prepareDockerEnv() throws Exception {

	final Logger logger = Logger.getLogger( DockerHandlerWithContainerTest.class.getName());
	try {
		// Is Docker installed?
		DockerTestUtils.checkDockerIsInstalled();

		// Prepare the environment
		DockerClient docker = buildDockerClient();
		File baseDir = new File( Thread.currentThread().getContextClassLoader().getResource( "./image/alpine" ).getFile());
		Assert.assertTrue( baseDir.exists());

		String builtImageId = docker.buildImageCmd(baseDir)
				.withNoCache( true ).withTags( new HashSet<>( Arrays.asList( TAG )))
				.exec( new RoboconfBuildImageResultCallback())
				.awaitImageId();

		logger.finest( "Built image ID: " + builtImageId );

		List<Image> images = docker.listImagesCmd().exec();
		images = images == null ? new ArrayList<Image>( 0 ) : images;
		Image img = DockerUtils.findImageByTag( TAG, images );

		Assert.assertNotNull( img );
		dockerImageId = img.getId();
		docker.close();

	} catch( IOException | InterruptedException e ) {
		logger.warning( "Tests are skipped because Docker is not installed or misconfigured." );
		Utils.logException( logger, e );

		dockerIsInstalled = false;
		Assume.assumeNoException( e );
	}
}
 
Example 13
Source File: MetaCycGateway.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public String[] findCompounds(double mass, MZTolerance mzTolerance, int numOfResults,
    ParameterSet parameters) throws IOException {

  final double ppmTolerance = mzTolerance.getPpmToleranceForMass(mass);

  final String queryAddress = metaCycSearchAddress + mass + "&tol=" + ppmTolerance;

  final URL queryURL = new URL(queryAddress);

  final Logger logger = Logger.getLogger(this.getClass().getName());

  // Submit the query
  logger.finest("Retrieving " + queryAddress);
  final String queryResult = InetUtils.retrieveData(queryURL);

  final List<String> results = new ArrayList<String>();
  BufferedReader lineReader = new BufferedReader(new StringReader(queryResult));
  String line;
  while ((line = lineReader.readLine()) != null) {
    String split[] = line.split("\\t");
    if (split.length < 5)
      continue;
    String id = split[4];
    results.add(id);
    if (results.size() == numOfResults)
      break;
  }

  return results.toArray(new String[0]);

}
 
Example 14
Source File: RandomUtils.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 15
Source File: JMonkeyEngineTest.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Test
public void testLogger() {
    final Logger logger = Logger.getLogger("Testlogger");
    logger.setLevel(Level.INFO);
    logger.config("config");
    logger.fine("fine");
    logger.finer("finer");
    logger.finest("finest");
    logger.info("info");
    logger.severe("severe");
    logger.warning("warning");
}
 
Example 16
Source File: MetaCycGateway.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public String[] findCompounds(double mass, MZTolerance mzTolerance, int numOfResults,
    ParameterSet parameters) throws IOException {

  final double ppmTolerance = mzTolerance.getPpmToleranceForMass(mass);

  final String queryAddress = metaCycSearchAddress + mass + "&tol=" + ppmTolerance;

  final URL queryURL = new URL(queryAddress);

  final Logger logger = Logger.getLogger(this.getClass().getName());

  // Submit the query
  logger.finest("Retrieving " + queryAddress);
  final String queryResult = InetUtils.retrieveData(queryURL);

  final List<String> results = new ArrayList<String>();
  BufferedReader lineReader = new BufferedReader(new StringReader(queryResult));
  String line;
  while ((line = lineReader.readLine()) != null) {
    String split[] = line.split("\\t");
    if (split.length < 5)
      continue;
    String id = split[4];
    results.add(id);
    if (results.size() == numOfResults)
      break;
  }

  return results.toArray(new String[0]);

}
 
Example 17
Source File: DockerMonitoringHandler.java    From roboconf-platform with Apache License 2.0 4 votes vote down vote up
/**
 * Checks that a Docker container is running.
 * <p>
 * This method works even if Docker is not installed. In this case,
 * it will return <code>false</code>. Otherwise, it will check whether
 * a container with this name is running. If it is stopped or if it does
 * not exist, it will return <code>false</code>. It returns <code>true</code>
 * if and only if a container with this name exists, and if it is running.
 * </p>
 *
 * @param containerName a container name (not null)
 * @return true if Docker is available and a container with this name is running, false otherwise
 */
boolean containerIsRunning( String containerName ) {

	// This method is not static so that we can mock it in tests.

	/*
	 * At the beginning, it was decided we would use Docker's REST
	 * API to query Docker. Just like we do with the Docker target.
	 *
	 * Except this may not be the best solution.
	 * Indeed, using the REST API implies having a socket open. This
	 * could constitute a security breach. Besides, we would have to
	 * specify the (optional) credentials to connect to this API.
	 *
	 * Since for the moment, we only want to trigger a notification when
	 * a container is down, we can use a system command.
	 */

	boolean running = false;
	Logger logger = Logger.getLogger( DockerMonitoringHandler.class.getName());
	try {
		String[] cmd = new String[] {
				"docker",
				"inspect",
				"-f",
				"{{.State.Running}}",
				containerName
		};

		ExecutionResult res = ProgramUtils.executeCommandWithResult( logger, cmd, null, null, this.applicationName, this.scopedInstancePath);
		logger.finest( "Execution's result: " + res.getExitValue());
		logger.finest( "Execution's normal output: " + res.getNormalOutput());
		running = res.getExitValue() == 0 && Boolean.parseBoolean( res.getNormalOutput());

	} catch( Exception e ) {
		logger.severe( "An error occurred while verifying that " + containerName + " was still running (in Docker)." );
		Utils.logException( logger, e );
	}

	return running;
}
 
Example 18
Source File: TestInferCaller.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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 19
Source File: TestInferCaller.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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 20
Source File: RandomUtils.java    From freecol with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}