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

The following examples show how to use java.util.logging.Logger#info() . 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: ObjectsOidActionsAid.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Performs an action on an available IoT object.
 * 
 * @param entity Representation of the incoming JSON.
 * @return A task to perform an action was submitted.
 */
@Post("json")
public Representation accept(Representation entity) {
	String attrOid = getAttribute(ATTR_OID);
	String attrAid = getAttribute(ATTR_AID);
	String callerOid = getRequest().getChallengeResponse().getIdentifier();
	Map<String, String> queryParams = getQuery().getValuesMap();
	
	Logger logger = (Logger) getContext().getAttributes().get(Api.CONTEXT_LOGGER);
	
	if (attrOid == null || attrAid == null){
		logger.info("OID: " + attrOid + " AID: " + attrAid + " Given identifier does not exist.");
		throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, 
				"Given identifier does not exist.");
	}

	String body = getRequestBody(entity, logger);

	return startAction(callerOid, attrOid, attrAid, body, queryParams);
}
 
Example 2
Source File: MessageCounter.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Connector
 */
public MessageCounter(XMLConfiguration config, Logger logger) {
	
	this.config = config;
	this.logger = logger;
	
	nmConnector = new NeighbourhoodManagerConnector(config, logger);
	
	logger.info("Trying to load counters from file...");
	CountersPersistence = new Counters(config, logger);
	records = CountersPersistence.getRecords();
	count = CountersPersistence.getCountOfMessages();
	
	// Initialize max counters stored before sending - MAX 500 - DEFAULT 100
	countOfSendingRecords = config.getInt(CONFIG_PARAM_MAXRECORDS, CONFIG_DEF_MAXRECORDS);		
	if(countOfSendingRecords > 500) {
		countOfSendingRecords = 500;
	} 
}
 
Example 3
Source File: CheckIndexInlineSizes.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Compares inline sizes from nodes and print to log information about "problem" indexes.
 *
 * @param log Logger
 * @param res Indexes inline size.
 */
private void analyzeResults(
    Logger log,
    CheckIndexInlineSizesResult res
) {
    Map<String, Map<Integer, Set<UUID>>> indexToSizeNode = new HashMap<>();

    for (Map.Entry<UUID, Map<String, Integer>> nodeRes : res.inlineSizes().entrySet()) {
        for (Map.Entry<String, Integer> index : nodeRes.getValue().entrySet()) {
            Map<Integer, Set<UUID>> sizeToNodes = indexToSizeNode.computeIfAbsent(index.getKey(), x -> new HashMap<>());

            sizeToNodes.computeIfAbsent(index.getValue(), x -> new HashSet<>()).add(nodeRes.getKey());
        }
    }

    log.info("Found " + indexToSizeNode.size() + " secondary indexes.");

    Map<String, Map<Integer, Set<UUID>>> problems = indexToSizeNode.entrySet().stream()
        .filter(e -> e.getValue().size() > 1)
        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

    if (F.isEmpty(problems))
        log.info(INDEXES_INLINE_SIZE_ARE_THE_SAME);
    else
        printProblemsAndShowRecommendations(problems, log);
}
 
Example 4
Source File: OcciVMUtils.java    From roboconf-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if VM is running.
 * @param hostIpPort
 * @param id
 * @return
 * @throws TargetException
 */
public static boolean isVMRunning(String hostIpPort, String id)
throws TargetException {
	boolean result = false;
	String ip = OcciVMUtils.getVMIP(hostIpPort, id);
	try {
		InetAddress inet = InetAddress.getByName(ip);
		result = inet.isReachable(5000);

	} catch (Exception e) {
		result = false;
		final Logger logger = Logger.getLogger( OcciVMUtils.class.getName());
		logger.info(e.getMessage());
	}

	return result;
}
 
Example 5
Source File: CacheCommands.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
private void printCacheHelp(Logger logger) {
    logger.info(INDENT + "The '" + CACHE + " subcommand' is used to get information about and perform actions" +
        " with caches. The command has the following syntax:");
    logger.info("");
    logger.info(INDENT + CommandLogger.join(" ", UTILITY_NAME, CommandLogger.join(" ", getCommonOptions())) + " " +
        CACHE + " [subcommand] <subcommand_parameters>");
    logger.info("");
    logger.info(INDENT + "The subcommands that take " + OP_NODE_ID + " as an argument ('" + LIST + "', '"
        + FIND_AND_DELETE_GARBAGE + "', '" + CONTENTION + "' and '" + VALIDATE_INDEXES +
        "') will be executed on the given node or on all server nodes" +
        " if the option is not specified. Other commands will run on a random server node.");
    logger.info("");
    logger.info("");
    logger.info(INDENT + "Subcommands:");

    Arrays.stream(CacheCommandList.values()).forEach(c -> {
        if (c.subcommand() != null) c.subcommand().printUsage(logger);
    });

    logger.info("");
}
 
Example 6
Source File: AgentsAgidObjects.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Register the IoT object(s) of the underlying eco-system e.g. devices, VA service.
 * 
 * @param entity Representation of the incoming JSON. List of IoT thing descriptions that are to be registered 
 * (from request).
 * @return All VICINITY identifiers of objects registered under VICINITY Gateway by this call.
 * 
 */
@Post("json")
public Representation accept(Representation entity) {
	
	String attrAgid = getAttribute(ATTR_AGID);
	
	Logger logger = (Logger) getContext().getAttributes().get(Api.CONTEXT_LOGGER);
	XMLConfiguration config = (XMLConfiguration) getContext().getAttributes().get(Api.CONTEXT_CONFIG);
	
	
	if (attrAgid == null){
		logger.info("AGID: " + attrAgid + " Invalid Agent ID.");
		throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, 
				"Invalid Agent ID.");
	}
	
	if (!entity.getMediaType().equals(MediaType.APPLICATION_JSON)){
		logger.info("AGID: " + attrAgid + " Invalid object descriptions.");
		
		throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, 
				"Invalid object descriptions");
	}
	
	return storeObjects(entity, logger, config);
}
 
Example 7
Source File: AgentsAgidObjectsUpdate.java    From vicinity-gateway-api with GNU General Public License v3.0 6 votes vote down vote up
@Put("json")
public Representation store(Representation entity) {
	
	String attrAgid = getAttribute(ATTR_AGID);
	
	Logger logger = (Logger) getContext().getAttributes().get(Api.CONTEXT_LOGGER);
	XMLConfiguration config = (XMLConfiguration) getContext().getAttributes().get(Api.CONTEXT_CONFIG);
	
	if (attrAgid == null){
		logger.info("AGID: " + attrAgid + " Invalid Agent ID.");
		throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, 
				"Invalid Agent ID.");
	}
	
	if (!entity.getMediaType().equals(MediaType.APPLICATION_JSON)){
		logger.info("AGID: " + attrAgid + " Invalid object descriptions.");
		
		throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, 
				"Invalid object descriptions");
	}
	
	return lightweightUpdate(entity, logger, config);
}
 
Example 8
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 9
Source File: Worker.java    From lancoder with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void masterTimeout() {
	Logger logger = Logger.getLogger("lancoder");
	logger.info("Lost connection to master !%n");

	for (ClientTask task : this.getCurrentTasks()) {
		stopWork(task);
	}
	this.updateStatus(NodeState.NOT_CONNECTED);
}
 
Example 10
Source File: MetadataListCommand.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected void printResult(MetadataListResult res, Logger log) {
    for (BinaryMetadata m : res.metadata()) {
        log.info("typeId=" + printInt(m.typeId()) +
            ", typeName=" + m.typeName() +
            ", fields=" + m.fields().size() +
            ", schemas=" + m.schemas().size() +
            ", isEnum=" + m.isEnum());
    }
}
 
Example 11
Source File: AbstractLoggerTest.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testGlobalLogger() throws Exception {
    final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
    root.info("Test info message");
    root.config("Test info message");
    root.fine("Test info message");
    final List<LogEvent> events = eventAppender.getEvents();
    assertThat(events, hasSize(3));
    for (final LogEvent event : events) {
        final String message = event.getMessage().getFormattedMessage();
        assertThat(message, equalTo("Test info message"));
    }
}
 
Example 12
Source File: SkyBlockHook.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private static void printHookInfo(CompatibilitySkyBlock expansion, String pluginName) {
    PluginManager manager = Bukkit.getPluginManager();
    if(!manager.isPluginEnabled(pluginName)) return;
    
    Plugin plugin = manager.getPlugin(pluginName);
    if(plugin == null) return;

    PluginDescriptionFile description = plugin.getDescription();
    String fullName = description.getFullName();
    
    Logger logger = expansion.getLogger();
    logger.info("Successfully hooked into " + fullName);
}
 
Example 13
Source File: CombatLogX.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void printDebug(String message) {
    if(message == null || message.isEmpty()) return;
    
    FileConfiguration config = getConfig("config.yml");
    if(!config.getBoolean("debug")) return;
    
    Logger logger = getLogger();
    logger.info("[Debug] " + message);
}
 
Example 14
Source File: VersionDependency.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if the underlying resource has changed.
 */
public boolean logModified(Logger log)
{
  if (! CauchoUtil.getFullVersion().equals(_version)) {
    log.info("Baratine version has changed to " + CauchoUtil.getFullVersion());
    return true;
  }
  else
    return false;
}
 
Example 15
Source File: MetadataUpdateCommand.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected void printResult(MetadataMarshalled res, Logger log) {
    if (res.metadata() == null) {
        log.info("Type not found");

        return;
    }

    BinaryMetadata m = res.metadata();

    log.info("Metadata updated for the type: '" + m.typeName() + '\'');
}
 
Example 16
Source File: HTTPClient.java    From amadeus-java with MIT License 4 votes vote down vote up
private void log(Object object) {
  if (getConfiguration().getLogLevel() == "debug") {
    Logger logger = getConfiguration().getLogger();
    logger.info(object.toString());
  }
}
 
Example 17
Source File: Debugger.java    From BedWars with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void info(String debug) {
    Logger logger = Logger.getLogger("BedWars");
    logger.info(debug);
}
 
Example 18
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 19
Source File: ObjectsOidEvents.java    From vicinity-gateway-api with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Answers the GET call
 * 
 * @return A {@link StatusMessage StatusMessage} 
 */
@Get
public Representation represent(Representation entity) {
	
	String attrOid = getAttribute(ATTR_OID);
	String callerOid = getRequest().getChallengeResponse().getIdentifier();
	Map<String, String> queryParams = getQuery().getValuesMap();
	
	Logger logger = (Logger) getContext().getAttributes().get(Api.CONTEXT_LOGGER);
	
	if (attrOid == null){
		
		logger.info("OID: " + attrOid + " Given identifier does not exist.");
		
		throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, 
				"Given identifier does not exist.");
	}
	

	String body = getRequestBody(entity, logger);
	
	return getObjectEvents(callerOid, attrOid, body, queryParams);
	
}
 
Example 20
Source File: JdkLoggerTest.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Ignore
@Test
public void test() {
    Logger logger = Logger.getLogger(this.getClass().getName());

    logger.info("tset");

    // formatting is not supported
    logger.log(Level.INFO, "Test %s", "sdfsdf");

    logger.log(Level.INFO, "Test ", new Exception());

    logger.logp(Level.INFO, JdkLoggerTest.class.getName(), "test()", "tsdd");

    // Should not log this because log level for test defined in logging.properties is "fine".
    logger.finest("logged?");

}