Example usage for java.util.logging Logger info

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

Introduction

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

Prototype

public void info(Supplier<String> msgSupplier) 

Source Link

Document

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

Usage

From source file:mockit.integration.logging.LoggingIntegrationsTest.java

@Test
public void jdkLoggingShouldLogNothing() {
    Logger log1 = Logger.getAnonymousLogger();
    Logger log2 = Logger.getAnonymousLogger("bundle");
    Logger log3 = Logger.getLogger(LoggingIntegrationsTest.class.getName());
    Logger log4 = Logger.getLogger(LoggingIntegrationsTest.class.getName(), "bundle");

    assertFalse(log1.isLoggable(Level.ALL));
    log1.severe("testing that logger does nothing");
    log2.setLevel(Level.WARNING);
    log2.info("testing that logger does nothing");
    log3.warning("testing that logger does nothing");
    log4.fine("testing that logger does nothing");
    log4.finest("testing that logger does nothing");
}

From source file:net.itransformers.topologyviewer.fulfilmentfactory.impl.TelnetCLIInterface.java

public TelnetCLIInterface(String host, String user, String password, String prompt, int timeout,
        Logger logger) {
    this.host = host;
    this.user = user;
    this.password = password;
    this.timeout = timeout;
    //        this.prompt = host + ">"; // todo config this
    //        this.prompt = "R112>"; // todo config this
    this.prompt = prompt;
    this.logger = logger;
    logger.info(String.format(
            "Crating telnet cli interface. host: %s, port: %s, user: %s, pass: %s, timeout: %s, prompt: %s",
            host, port, user, password, timeout, prompt));
}

From source file:bigtweet.BTSimBatch.java

/**
 * Read a input batch file with set of experiments (one line for parameters
 * configuration) and execute them The file is generated with R
 *///from  w w w.  j ava  2 s.c o m
public void runBatchExperiments() {

    generateSeeds();
    generateExperimentResultsObjects();
    loadBatchInputFile();
    loadBatchOutputFile();

    Logger LOG = Logger.getLogger(BTSimBatch.class.getName()); //log variable, the attribute would not read "./configuration/logging.properties

    for (int i = 0; i < parametersValues.size(); i++) {
        JSONObject jo = (JSONObject) parametersValues.get(i);
        LOG.info("Parameters " + jo.toString());
        if (i < this.experimentConducted) {//skip experiments already conducted
            LOG.info("ALREADY DONE IN PREVIOUS EXECUTION (" + i + " of " + parametersValues.size() + ")");
            continue;
        }

        for (int seed = 0; seed < NSEEDS; seed++) {
            LOG.info("Seed: " + seed);
            BTSim bt = new BTSim(seed);
            bt.setParametersSetForBatch(jo);
            bt.start();

            while (bt.schedule.step(bt)) {
            } //execute simulation until finishing

            for (BatchExperimentsResults r : resultsForDatasets) {//for each dataset, add distance for the seed
                r.addResultsForSeed(bt, new Long(seed));
            }

        }
        updateOutputJsonFile(i);
        LOG.info("DONE (" + (i + 1) + " of " + parametersValues.size() + ")");

    }

}

From source file:uk.org.lidalia.sysoutslf4j.integration.TestSysOutOverSlf4J.java

@Test
public void juliConsoleAppenderStillLogsToConsole() throws Exception {
    OutputStream newSysErr = setUpMockSystemOutput(SystemOutput.ERR);
    SysOutOverSLF4J.sendSystemOutAndErrToSLF4J();

    java.util.logging.Logger log = java.util.logging.Logger.getLogger("");
    for (Handler handler : log.getHandlers()) {
        log.removeHandler(handler);/* w ww.  j ava2s .  com*/
    }
    log.addHandler(new ConsoleHandler());
    log.info("Should reach the old syserr");

    assertThat(newSysErr.toString(), containsString("INFO: Should reach the old syserr"));
}

From source file:lucel_updater.models.FTPClientManager.java

public FTPClientManager() {

    Logger logger = Logger.getLogger("MyLog");
    FileHandler fh;//from   www .j a v a  2 s.  c  o m

    try {
        // This block configure the logger with handler and formatter
        /*fh = new FileHandler("C:/lucel.log");
        logger.addHandler(fh);
        SimpleFormatter formatter = new SimpleFormatter();
        fh.setFormatter(formatter);*/

        URL loc = FTPClient.class.getProtectionDomain().getCodeSource().getLocation();
        logger.info("Class: " + FTPClient.class.getSimpleName() + " loaded from " + loc);

        //this.ftpClient = new FTPClient();
        this.ftpClient = new Ftp();
        ftpClient.getContext().setFileTransferMode('I');

        logger.info("OK FTP !");

    } catch (Exception e) {
        e.printStackTrace();
        Logger.getLogger(this.getClass().getName()).warning("e=" + e.getMessage());
        System.out.println(e.getMessage());
        logger.info(e.getMessage());
    }

}

From source file:ste.xtest.net.StubURLConnection.java

/**
 * Stubs the connection action to the resource. It also executes the 
 * provided <code>StubConnectionCall</code> if any.
 * /*  ww w . jav  a 2  s. c  o m*/
 * @throws IOException in case of connection errors
 * @throws IllegalStateException if already connected
 */
@Override
public void connect() throws IOException {
    if (connected) {
        throw new IllegalStateException("Already connected");
    }

    Logger LOG = Logger.getLogger("ste.xtest.net");
    if (LOG.isLoggable(Level.INFO)) {
        LOG.info("connecting to " + url);
        LOG.info("request headers: " + getRequestProperties());
        LOG.info("response headers: " + headers);
    }

    if (exec != null) {
        try {
            LOG.info("executing connection code");
            exec.call(this);
        } catch (IOException x) {
            throw x;
        } catch (Exception x) {
            throw new IOException(x.getMessage(), x);
        }
    }

    connected = true;
}

From source file:ste.xtest.net.StubURLConnection.java

@Override
public InputStream getInputStream() throws IOException {
    connectIfNeeded();//from   www  .j  av  a 2  s  . c  om

    if (content == null) {
        return null;
    }

    Logger LOG = Logger.getLogger("ste.xtest.net");

    if (content instanceof String) {
        if (LOG.isLoggable(Level.INFO)) {
            LOG.info("returning input stream from provided text");
        }
        return new ByteArrayInputStream(((String) content).getBytes());
    } else if (content instanceof Path) {
        if (LOG.isLoggable(Level.INFO)) {
            LOG.info("returning input stream from file " + ((Path) content).toAbsolutePath());
        }
        return Files.newInputStream((Path) content);
    } else if (content instanceof InputStream) {
        if (LOG.isLoggable(Level.INFO)) {
            LOG.info("returning input stream from reader");
        }
        return ((InputStream) content);
    }

    if (LOG.isLoggable(Level.INFO)) {
        LOG.info("returning input stream from provided data");
    }
    return new ByteArrayInputStream((byte[]) content);
}

From source file:com.yahoo.dba.perf.myperf.common.MyPerfContext.java

/**
 * All the top level beans, sql manager, connection manage, db manager, etc, will be initialized here.
 *//*from  w  w w.  j  a v  a 2 s. c  o m*/
public void afterPropertiesSet() throws Exception {
    configureLogging();
    Logger logger = Logger.getLogger(this.getClass().getName());
    logger.info("Setup afterPropertiesSet.");

    logger.info("Loading JDBC Drivers");
    if (this.jdbcDriver != null) {
        DriverManager.setLoginTimeout(60);
        logger.info("Set JDBC DriverManager loginTimeout as 60 seconds");
        for (Map.Entry<String, String> e : jdbcDriver.entrySet()) {
            logger.info("Loading " + e.getKey() + ": " + e.getValue());
            try {
                Class.forName(e.getValue());
                logger.info("Loaded " + e.getKey() + ": " + e.getValue());
            } catch (Throwable ex) {
                logger.info("Failed to Load " + e.getKey() + ": " + e.getValue());
            }
        }
    }

    alertRootPath = new File(new File(this.fileReposirtoryPath), "alerts");
    alertRootPath.mkdirs();

    this.sqlManager.setSqlPath(sqlPath);
    this.sqlManager.init();

    this.metricsDef.init();
    logger.info("Refreshing metrics list ...");
    refreshMetricsList();
    logger.info("Retrieved metrics list: " + this.metricsList.size());

    this.metaDb.setDbkey(this.configRepKey);
    this.metaDb.init();

    this.dbInfoManager.setMetaDb(metaDb);//since we store db info now in metricsdb, 
    //it can only be initialized after metricsDB initialized 

    this.userManager.setMetaDb(metaDb);
    this.auth.setContext(this);
    this.queryEngine.setSqlManager(this.sqlManager);
    this.queryEngine.setFrameworkContext(this);
    this.statDefManager.init();

    logger.info("Initialize AutoScanner ...");
    this.myperfConfig.init(this);
    if (this.myperfConfig.isConfigured()) {
        this.initMetricsDB(); //move metrics db creation and initialization away from scanner
        this.alertSettings.setContext(this);
        if (this.metricDb != null) {
            this.dbInfoManager.init(this.metricDb);//need metricsDB to update
            this.metricsDef.getUdmManager().loadSubscriptions(this);
            this.metricDb.loadAlertSetting(this.alertSettings);//load alert setting after DB info is loaded.
        }
    }
    this.instanceStatesManager.init(this);

    autoScanner = new AutoScanner(this);
    autoScanner.init();//it will update metricsDB
    if (autoScanner.isInitialized()) {
        logger.info("Starting AutoScanner ...");
        autoScanner.start();
    }

    logger.info("Done setup afterPropertiesSet.");
}

From source file:org.conf4j.service.ConfServiceInstance.java

@Override
public final void initFolders() {
    final Logger log = Logger.getLogger(LOGGER_CAT);
    final List<String> propertyNames = getKeys();
    for (int i = 0; i < propertyNames.size(); i++) {
        final String propertyName = propertyNames.get(i);
        if (!propertyName.endsWith("_dir")) {
            continue;
        }//ww  w. j  av  a  2 s  .  c  om
        final String folderPath = getValue(propertyName);
        if (folderPath == null || folderPath.trim().length() <= 0) {
            log.info(DIR_VAR_0_NOT_SET.format(new String[] { propertyName }));
            continue;
        }
        final File folderFile = new File(folderPath);
        try {
            if (!folderFile.exists()) {
                final boolean success = folderFile.mkdirs();
                if (success) {
                    log.log(Level.INFO, DIR_VAR_0_PATH_1_CREATED_ABSPATH_2
                            .format(new String[] { propertyName, folderPath, folderFile.getAbsolutePath() }));
                } else {
                    log.log(Level.SEVERE,
                            DIR_VAR_0_PATH_1_CREATION_FAILED.format(new String[] { propertyName, folderPath }));
                }
            } else {
                log.log(Level.INFO, DIR_VAR_0_PATH_1_EXISTS.format(new String[] { propertyName, folderPath }));
            }
        } catch (SecurityException e) {
            log.log(Level.WARNING,
                    DIR_VAR_0_PATH_1_CHECKS_FAILURE.format(new String[] { propertyName, folderPath }));
        }
    }
}

From source file:org.blazr.extrastorage.ExtraStorage.java

public void onDisable() {
    Logger log = getLogger();
    try {/*from ww w.  ja v  a  2  s .co  m*/
        IO.save(this);
    } catch (Exception e) {
        log.severe("Error saving inventories during disable! Backpacks may not be saved properly!");
        e.printStackTrace();
    }
    log.info("Disabled!");
}