Example usage for java.util.logging Logger log

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

Introduction

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

Prototype

public void log(Level level, Throwable thrown, Supplier<String> msgSupplier) 

Source Link

Document

Log a lazily constructed message, with associated Throwable information.

Usage

From source file:bizlogic.Records.java

public static void list(Connection DBcon) throws IOException, ParseException, SQLException {

    Statement st;//from  w  w  w  . j  a  va2s. c  om
    ResultSet rs = null;

    try {
        st = DBcon.createStatement();
        rs = st.executeQuery("SELECT userconf.log_list.sensor_id, " + "userconf.log_list.smpl_interval, "
                + "userconf.log_list.running, " + "userconf.log_list.name AS log_name, "
                + "userconf.log_list.log_id, " + "userconf.sensorlist.name AS sensor_name "
                + "FROM USERCONF.LOG_LIST " + "JOIN userconf.sensorlist "
                + "ON userconf.log_list.sensor_id=userconf.sensorlist.sensor_id");

    } catch (SQLException ex) {
        Logger lgr = Logger.getLogger(Records.class.getName());
        lgr.log(Level.SEVERE, ex.getMessage(), ex);
    }

    try {
        FileWriter recordsFile = new FileWriter("/var/lib/tomcat8/webapps/ROOT/Records/records.json");
        //BufferedWriter recordsFile = new BufferedWriter(_file);
        //recordsFile.write("");
        //recordsFile.flush(); 

        FileReader fr = new FileReader("/var/lib/tomcat8/webapps/ROOT/Records/records.json");
        BufferedReader br = new BufferedReader(fr);

        JSONObject Records = new JSONObject();

        int _total = 0;

        JSONArray recordList = new JSONArray();

        while (rs.next()) {

            String isRunningStr;

            JSONObject sensor_Obj = new JSONObject();

            int sensor_id = rs.getInt("sensor_id");
            sensor_Obj.put("sensor_id", sensor_id);

            String smpl_interval = rs.getString("smpl_interval");
            sensor_Obj.put("smpl_interval", smpl_interval);

            Boolean running = rs.getBoolean("running");
            if (running) {
                //System.out.print("1");
                isRunningStr = "ON";
            } else {
                //System.out.print("0");
                isRunningStr = "OFF";
            }
            sensor_Obj.put("running", isRunningStr);

            String log_name = rs.getString("log_name");
            sensor_Obj.put("log_name", log_name);

            String sensor_name = rs.getString("sensor_name");
            sensor_Obj.put("sensor_name", sensor_name);

            int log_id = rs.getInt("log_id");
            sensor_Obj.put("recid", log_id);

            recordList.add(sensor_Obj);
            _total++;

        }

        rs.close();

        Records.put("total", _total);
        Records.put("records", recordList);

        recordsFile.write(Records.toJSONString());
        recordsFile.flush();

        recordsFile.close();

        System.out.print(Records.toJSONString());
        System.out.print(br.readLine());

    }

    catch (IOException ex) {
        Logger.getLogger(Records.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

protected static void log(Logger logger, ChronicleLogLevel level, String fmt, Object... args) {
    switch (level) {
    case TRACE://w ww .ja va 2 s .co m
        logger.log(Level.ALL, fmt, args);
        break;
    case DEBUG:
        logger.log(Level.FINE, fmt, args);
        break;
    case INFO:
        logger.log(Level.INFO, fmt, args);
        break;
    case WARN:
        logger.log(Level.WARNING, fmt, args);
        break;
    case ERROR:
        logger.log(Level.SEVERE, fmt, args);
        break;
    default:
        throw new UnsupportedOperationException();
    }
}

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;/*from  ww w .j a va 2  s.c  o m*/
    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:com.stratuscom.harvester.Utils.java

public static void logGrantsToClass(final Logger log, final Level level, final Class c) {
    AccessController.doPrivileged(new PrivilegedAction<Object>() {
        public Object run() {
            ClassLoader cl = c.getClassLoader();
            DynamicPolicyProvider dpp = (DynamicPolicyProvider) Policy.getPolicy();
            Permission[] perms = dpp.getGrants(c, null);
            log.log(level, MessageNames.GRANTS_TO_CLASS_ARE, new Object[] { c.getName(), Utils.format(perms) });
            return null;
        }//from w  ww .  ja v a 2 s .  co m
    });
}

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   w w w. ja  va 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:pcgen.util.Logging.java

/**
 * Log a message with a stack trace, if logging is enabled at the
 * supplied level of detail. //  w ww  .  j  a  v  a  2 s . co  m
 * 
 * @param lvl The detail level of the message
 * @param msg String message
 * @param thr Throwable stack frame
 */
public static void log(final Level lvl, final String msg, final Throwable thr) {
    Logger l = getLogger();
    if (l.isLoggable(lvl)) {
        l.log(lvl, msg, thr);
    }
}

From source file:pcgen.util.Logging.java

/**
 * Log a message with a stack trace, if logging is enabled at the
 * supplied level of detail. //from  w  ww  . j  av a 2 s  .  co  m
 * This is mainly for use with the pcgen.rules.persistence.token.ParseResult class.
 * 
 * @param lvl        The detail level of the message
 * @param msg        String message
 * @param stackTrace The stack trace
 */
public static void log(Level lvl, String msg, StackTraceElement[] stackTrace) {
    Logger l = getLogger();
    if (l.isLoggable(lvl)) {
        l.log(lvl, msg, stackTrace);
    }
}

From source file:pcgen.util.Logging.java

/**
 * Beep and print error message if PCGen is debugging.
 *
 * @param s String error message/*from  ww w . j  a  va2s .c  o  m*/
 * @param params Varargs list of parameters for substitution into the 
 * error message.
 */
public static void errorPrint(final String s, final Object... params) {
    if (debugMode) {
        S_TOOLKIT.beep();
    }

    Logger l = getLogger();
    if (l.isLoggable(ERROR)) {
        l.log(ERROR, s, params);
    }
}

From source file:pcgen.util.Logging.java

public static void replayParsedMessages() {
    Logger l = getLogger();
    for (QueuedMessage msg : queuedMessages) {
        if (l.isLoggable(msg.level)) {
            l.log(msg.level, msg.message, msg.stackTrace);
        }//from  w w w .  j  av  a2  s.c o  m

    }
    queuedMessageMark = -1;
}

From source file:org.openconcerto.sql.model.SQLBase.java

static public final void logCacheError(final DBItemFileCache dir, Exception e) {
    final Logger logger = Log.get();
    if (logger.isLoggable(Level.CONFIG))
        logger.log(Level.CONFIG, "invalid files in " + dir, e);
    else/*from  w w w  .j  av  a2  s  . c om*/
        logger.info("invalid files in " + dir + "\n" + e.getMessage());
}