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:org.wor.drawca.DrawCAMain.java

/**
 * Main function which start drawing the cellular automata.
 *
 * @param args Command line arguments.//w ww  .  j av a  2s  .  c  o m
 */
public static void main(final String[] args) {
    final Logger log = Logger.getGlobal();
    LogManager.getLogManager().reset();

    Options options = new Options();
    boolean hasArgs = true;

    // TODO: show defaults in option description
    options.addOption("h", "help", !hasArgs, "Show this help message");
    options.addOption("pci", "perclickiteration", !hasArgs, "Generate one line per mouse click");

    options.addOption("v", "verbose", hasArgs, "Verbosity level [-1,7]");
    options.addOption("r", "rule", hasArgs, "Rule number to use 0-255");
    options.addOption("wh", "windowheigth", hasArgs, "Draw window height");
    options.addOption("ww", "windowwidth", hasArgs, "Draw window width");
    options.addOption("x", "xscalefactor", hasArgs, "X Scale factor");
    options.addOption("y", "yscalefactor", hasArgs, "Y scale factor");
    options.addOption("f", "initline", hasArgs, "File name with Initial line.");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        e.printStackTrace();
        showHelp(options);
        return;
    }

    // Options without an argument
    if (cmd.hasOption("h")) {
        showHelp(options);
        return;
    }
    final boolean perClickIteration = cmd.hasOption("pci");

    // Options with an argument
    final int verbosityLevel = Integer.parseInt(cmd.getOptionValue('v', "0"));
    final int rule = Integer.parseInt(cmd.getOptionValue('r', "110"));
    final int windowHeigth = Integer.parseInt(cmd.getOptionValue("wh", "300"));
    final int windowWidth = Integer.parseInt(cmd.getOptionValue("ww", "400"));
    final float xScaleFactor = Float.parseFloat(cmd.getOptionValue('x', "2.0"));
    final float yScaleFactor = Float.parseFloat(cmd.getOptionValue('y', "2.0"));
    final String initLineFile = cmd.getOptionValue('f', "");

    final Level logLevel = VERBOSITY_MAP.get(verbosityLevel);
    log.setLevel(logLevel);

    // Set log handler
    Handler consoleHandler = new ConsoleHandler();
    consoleHandler.setLevel(logLevel);
    log.addHandler(consoleHandler);

    log.info("Log level set to: " + log.getLevel());

    // Read initial line from a file
    String initLine = "";
    if (initLineFile.length() > 0) {
        Path initLineFilePath = FileSystems.getDefault().getPath(initLineFile);
        try {
            // Should be string of ones and zeros only
            initLine = new String(Files.readAllBytes(initLineFilePath), "UTF-8");
        } catch (IOException e) {
            System.err.format("IOException: %s\n", e);
            return;
        }
    }

    SwingUtilities.invokeLater(new RunGUI(windowWidth, windowHeigth, xScaleFactor, yScaleFactor, rule, initLine,
            perClickIteration));
}

From source file:org.activiti.cycle.impl.connector.signavio.SignavioLogHelper.java

public static void logJSONArray(Logger log, JSONArray jsonArray) {
    try {/*from  w w  w.  j av a 2s. c o m*/
        log.info(jsonArray.toString(2));
    } catch (JSONException je) {
        log.log(Level.SEVERE, "JSONException while trying to log JSONArray", je);
    }
}

From source file:Main.java

public static void Sleep(long l, Logger log) {

    try {// w w w  .  ja  v  a  2  s .  c  om
        Thread.sleep(l);
    }

    catch (InterruptedException e) {

        log.info("Impossible to terminate Thread\n");
        return;
    }
}

From source file:io.trivium.anystore.StoreUtils.java

public static void cleanQueue() {
    Logger logger = Logger.getLogger(StoreUtils.class.getName());
    logger.info("cleaning queue storage");
    String path = Central.getProperty("basePath");
    if (!path.endsWith(File.separator))
        path += File.separator;// w  w  w  .ja  v a 2 s  .  c  om
    try {
        File f = new File(path + "queues" + File.separator);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning queue storage failed", e1);
    }
}

From source file:io.trivium.anystore.StoreUtils.java

public static void cleanStore() {
    Logger logger = Logger.getLogger(StoreUtils.class.getName());
    logger.info("cleaning persistence store");
    String path = Central.getProperty("basePath");
    if (!path.endsWith(File.separator))
        path += File.separator;/*from   ww w.jav  a  2s  .co m*/
    path += "store" + File.separator;
    try {
        File f = new File(path + meta);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning meta store failed", e1);
    }
    try {
        File f = new File(path + data);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning data store failed", e1);
    }
    try {
        File f = new File(path + local);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning local store failed", e1);
    }
}

From source file:org.jboss.as.test.integration.osgi.logging.bundle.LoggingDelegate.java

public static void assertJULLogging(String message) {
    java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggingDelegate.class.getName());

    String loggerClass = log.getClass().getName();

    if ("org.jboss.logmanager.Logger".equals(loggerClass) == false)
        throw new IllegalStateException("Unexpected logger: " + loggerClass);

    log.info("*******************************************");
    log.info("* JUL: " + message);
    log.info("*******************************************");
}

From source file:net.openhft.chronicle.logger.jul.JulTestBase.java

protected static void warmup(Logger logger) {
    final String str = StringUtils.rightPad("X", 64);
    for (int i = 0; i < 10; i++) {
        logger.info(str);
    }// www . j a v a2s.c  o  m
}

From source file:org.schemaspy.view.HtmlFormatter.java

/**
 * Encode the specified string//from   w  w w .  j  a v  a 2 s  . c o m
 *
 * @param string
 * @return
 */
static String urlEncode(String string) {
    try {
        return URLEncoder.encode(string, Config.DOT_CHARSET);
    } catch (UnsupportedEncodingException e) {
        Logger logger = Logger.getLogger(HtmlFormatter.class.getName());
        logger.info(
                "Error trying to urlEncode string [" + string + "] with encoding [" + Config.DOT_CHARSET + "]");
        return string;
    }
}

From source file:eu.wordnice.wnconsole.WNCUtils.java

/*** PROTECTED ***/
protected static Handler.OneVoidHandler<Logger> createOnDisable(final ServerSocket sock) {
    return new Handler.OneVoidHandler<Logger>() {
        @Override//from   w  ww .  j a  v  a  2 s. c o m
        public void handle(Logger lg) {
            try {
                sock.close();
                lg.info("WNConsole was disabled!");
            } catch (Throwable tr) {
                lg.severe("Ups, cannot close server service! Details:");
                tr.printStackTrace();
            }
        }
    };
}

From source file:at.pcgamingfreaks.Utils.java

/**
 * Shows a warning message if the Java version is still 1.7.
 *
 * @param logger The logger to output the warning
 * @param pauseTime The time in seconds the function should be blocking (in seconds) if Java is outdated. Values below 1 wont block.
 *///from   ww w.j  a va  2  s  .c om
public static void warnOnJava_1_7(@NotNull Logger logger, int pauseTime) {
    Validate.notNull(logger, "The logger must not be null.");
    if (System.getProperty("java.version").startsWith("1.7")) {
        logger.warning(ConsoleColor.RED
                + "You are still using Java 1.7. Java 1.7 is EOL for over a year now! You should really update to Java 1.8!"
                + ConsoleColor.RESET);
        logger.info(ConsoleColor.YELLOW
                + "For now this plugin will still work fine with Java 1.7 but no warranty that this won't change in the future."
                + ConsoleColor.RESET);
        blockThread(pauseTime);
    }
}