Example usage for java.util.logging Level FINEST

List of usage examples for java.util.logging Level FINEST

Introduction

In this page you can find the example usage for java.util.logging Level FINEST.

Prototype

Level FINEST

To view the source code for java.util.logging Level FINEST.

Click Source Link

Document

FINEST indicates a highly detailed tracing message.

Usage

From source file:de.blinkenlights.bmix.main.Daemon.java

public void init(DaemonContext arg0) throws Exception {
    int verbosity = 1;
    if (System.getProperty("debugLevel") != null) {
        verbosity = Integer.parseInt(System.getProperty("debugLevel"));
    }//from   w  w w. ja v a 2s .  co m
    Level logLevel;
    if (verbosity == 0) {
        logLevel = Level.WARNING;
    } else if (verbosity == 1) {
        logLevel = Level.INFO;
    } else if (verbosity == 2) {
        logLevel = Level.FINE;
    } else if (verbosity >= 3) {
        logLevel = Level.FINEST;
    } else {
        System.err.println("Fatal Error: Invalid log verbosity: " + verbosity);
        return;
    }
    System.err.println("Setting log level to " + logLevel);
    Logger.getLogger("").setLevel(logLevel);
    for (Handler handler : Logger.getLogger("").getHandlers()) {
        handler.setLevel(logLevel);
    }

    bmix = new BMix("bmix.xml", false);
}

From source file:com.kijes.ela.android.ElaService.java

public ElaService(Handler handler, ElaServiceProperties props) {
    this.handler = handler;
    this.props = props;

    if (D) {/*  w  w w  .  j a  va  2  s.co  m*/
        Engine.setLogLevel(Level.FINEST);
        Engine.setRestletLogLevel(Level.FINEST);
    }
}

From source file:com.clothcat.hpoolauto.Main.java

private void checkHyperstakedRunning() {
    try {//from w w w .  j a  v a  2s . c o m
        HLogger.log(Level.FINEST, "checking wallet status");
        String s = rpcworker.checkwallet();
        HLogger.log(Level.FINEST, "Status returned: " + s);
        JSONObject j = new JSONObject(s);
        boolean pass = j.getBoolean("wallet check passed");
        if (pass) {
            HLogger.log(Level.FINEST, "Wallet status check passed");
        } else {
            HLogger.log(Level.SEVERE, "FAiled wallet status check!");
        }
    } catch (JSONException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:fr.gouv.vitam.utils.logging.CommonsLoggerFactory.java

@Override
protected void seLevelSpecific(final VitamLogLevel level) {
    // XXX FIXME does not work for Apache Commons Logger
    switch (level) {
    case TRACE:/*w  w w.  j  a v a2  s .com*/
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.FINEST);
        break;
    case DEBUG:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.FINE);
        break;
    case INFO:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.INFO);
        break;
    case WARN:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.WARNING);
        break;
    case ERROR:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.SEVERE);
        break;
    default:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.WARNING);
        break;
    }
}

From source file:com.google.cloud.runtime.jetty.util.HttpUrlUtil.java

/**
 * Wait for a server to be "up" by requesting a specific GET resource
 * that should be returned in status code 200.
 * <p>//from  w w w. j a  v  a  2s  .  c om
 * This will attempt a check for server up.
 * If any result other then response code 200 occurs, then
 * a 2s delay is performed until the next test.
 * Up to the duration/timeunit specified.
 * </p>
 *
 * @param uri      the URI to request
 * @param duration the time duration to wait for server up
 * @param unit     the time unit to wait for server up
 */
public static void waitForServerUp(URI uri, int duration, TimeUnit unit) {
    System.err.println("Waiting for server up: " + uri);
    boolean waiting = true;
    long expiration = System.currentTimeMillis() + unit.toMillis(duration);
    while (waiting && System.currentTimeMillis() < expiration) {
        try {
            System.out.print(".");
            HttpURLConnection http = openTo(uri);
            int statusCode = http.getResponseCode();
            if (statusCode != HttpURLConnection.HTTP_OK) {
                log.log(Level.FINER, "Waiting 2s for next attempt");
                TimeUnit.SECONDS.sleep(2);
            } else {
                waiting = false;
            }
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("Invalid URI: " + uri.toString());
        } catch (IOException e) {
            log.log(Level.FINEST, "Ignoring IOException", e);
        } catch (InterruptedException ignore) {
            // ignore
        }
    }
    System.err.println();
    System.err.println("Server seems to be up.");
}

From source file:eu.flatworld.worldexplorer.layer.nltl7.NLTL7HTTPProvider.java

@Override
public Tile getTile(int id, int x, int y, int l) throws Exception {
    Tile tile = null;//from  w ww.  j  a v a  2  s  . co m
    tile = new NLTL7Tile();
    tile.setX(x);
    tile.setY(y);
    tile.setGx(x);
    tile.setGy((int) Math.pow(2, l) * NLTL7Layer.SURFACE_HEIGHT - 1 - y);
    tile.setL(l);
    LogX.log(Level.FINEST, NAME + " queueing: " + tile);
    firePropertyChange(P_IDLE, true, false);
    queueTile(tile);
    return tile;
}

From source file:net.tradelib.apps.StrategyBacktest.java

public static void run(Strategy strategy) throws Exception {
    // Setup the logging
    System.setProperty("java.util.logging.SimpleFormatter.format",
            "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS: %4$s: %5$s%n%6$s%n");
    LogManager.getLogManager().reset();
    Logger rootLogger = Logger.getLogger("");
    if (Boolean.parseBoolean(BacktestCfg.instance().getProperty("file.log", "true"))) {
        FileHandler logHandler = new FileHandler("diag.out", 8 * 1024 * 1024, 2, true);
        logHandler.setFormatter(new SimpleFormatter());
        logHandler.setLevel(Level.FINEST);
        rootLogger.addHandler(logHandler);
    }//from   w  ww  .j  av  a  2s  . co  m

    if (Boolean.parseBoolean(BacktestCfg.instance().getProperty("console.log", "true"))) {
        ConsoleHandler consoleHandler = new ConsoleHandler();
        consoleHandler.setFormatter(new SimpleFormatter());
        consoleHandler.setLevel(Level.INFO);
        rootLogger.addHandler(consoleHandler);
    }

    rootLogger.setLevel(Level.INFO);

    // Setup Hibernate
    // Configuration configuration = new Configuration();
    // StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
    // SessionFactory factory = configuration.buildSessionFactory(builder.build());

    Context context = new Context();
    context.dbUrl = BacktestCfg.instance().getProperty("db.url");

    HistoricalDataFeed hdf = new SQLDataFeed(context);
    hdf.configure(BacktestCfg.instance().getProperty("datafeed.config", "config/datafeed.properties"));
    context.historicalDataFeed = hdf;

    HistoricalReplay hr = new HistoricalReplay(context);
    context.broker = hr;

    strategy.initialize(context);
    strategy.cleanupDb();

    long start = System.nanoTime();
    strategy.start();
    long elapsedTime = System.nanoTime() - start;
    System.out.println("backtest took " + String.format("%.2f secs", (double) elapsedTime / 1e9));

    start = System.nanoTime();
    strategy.updateEndEquity();
    strategy.writeExecutionsAndTrades();
    strategy.writeEquity();
    elapsedTime = System.nanoTime() - start;
    System.out
            .println("writing to the database took " + String.format("%.2f secs", (double) elapsedTime / 1e9));

    System.out.println();

    // Write the strategy totals to the database
    strategy.totalTradeStats();

    // Write the strategy report to the database and obtain the JSON
    // for writing it to the console.
    JsonObject report = strategy.writeStrategyReport();

    JsonArray asa = report.getAsJsonArray("annual_stats");

    String csvPath = BacktestCfg.instance().getProperty("positions.csv.prefix");
    if (!Strings.isNullOrEmpty(csvPath)) {
        csvPath += "-" + strategy.getLastTimestamp().toLocalDate().format(DateTimeFormatter.BASIC_ISO_DATE)
                + ".csv";
    }

    String ordersCsvPath = BacktestCfg.instance().getProperty("orders.csv.suffix");
    if (!Strings.isNullOrEmpty(ordersCsvPath)) {
        ordersCsvPath = strategy.getLastTimestamp().toLocalDate().format(DateTimeFormatter.BASIC_ISO_DATE) + "-"
                + strategy.getName() + ordersCsvPath;
    }

    String actionsPath = BacktestCfg.instance().getProperty("actions.file.suffix");
    if (!Strings.isNullOrEmpty(actionsPath)) {
        actionsPath = strategy.getLastTimestamp().toLocalDate().format(DateTimeFormatter.BASIC_ISO_DATE) + "-"
                + strategy.getName() + actionsPath;
    }

    // If emails are being send out
    String signalText = StrategyText.build(context.dbUrl, strategy.getName(),
            strategy.getLastTimestamp().toLocalDate(), "   ", csvPath, '|');

    System.out.println(signalText);
    System.out.println();

    if (!Strings.isNullOrEmpty(ordersCsvPath)) {
        StrategyText.buildOrdersCsv(context.dbUrl, strategy.getName(),
                strategy.getLastTimestamp().toLocalDate(), ordersCsvPath);
    }

    File actionsFile = Strings.isNullOrEmpty(actionsPath) ? null : new File(actionsPath);

    if (actionsFile != null) {
        FileUtils.writeStringToFile(actionsFile,
                signalText + System.getProperty("line.separator") + System.getProperty("line.separator"));
    }

    String message = "";

    if (asa.size() > 0) {
        // Sort the array
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        for (int ii = 0; ii < asa.size(); ++ii) {
            int year = asa.get(ii).getAsJsonObject().get("year").getAsInt();
            map.put(year, ii);
        }

        for (int id : map.values()) {
            JsonObject jo = asa.get(id).getAsJsonObject();
            String yearStr = String.valueOf(jo.get("year").getAsInt());
            String pnlStr = String.format("$%,d", jo.get("pnl").getAsInt());
            String pnlPctStr = String.format("%.2f%%", jo.get("pnl_pct").getAsDouble());
            String endEqStr = String.format("$%,d", jo.get("end_equity").getAsInt());
            String ddStr = String.format("$%,d", jo.get("maxdd").getAsInt());
            String ddPctStr = String.format("%.2f%%", jo.get("maxdd_pct").getAsDouble());
            String str = yearStr + " PnL: " + pnlStr + ", PnL Pct: " + pnlPctStr + ", End Equity: " + endEqStr
                    + ", MaxDD: " + ddStr + ", Pct MaxDD: " + ddPctStr;
            message += str + "\n";
        }

        String pnlStr = String.format("$%,d", report.get("pnl").getAsInt());
        String pnlPctStr = String.format("%.2f%%", report.get("pnl_pct").getAsDouble());
        String ddStr = String.format("$%,d", report.get("avgdd").getAsInt());
        String ddPctStr = String.format("%.2f%%", report.get("avgdd_pct").getAsDouble());
        String gainToPainStr = String.format("%.4f", report.get("gain_to_pain").getAsDouble());
        String str = "\nAvg PnL: " + pnlStr + ", Pct Avg PnL: " + pnlPctStr + ", Avg DD: " + ddStr
                + ", Pct Avg DD: " + ddPctStr + ", Gain to Pain: " + gainToPainStr;
        message += str + "\n";
    } else {
        message += "\n";
    }

    // Global statistics
    JsonObject jo = report.getAsJsonObject("total_peak");
    String dateStr = jo.get("date").getAsString();
    int maxEndEq = jo.get("equity").getAsInt();
    jo = report.getAsJsonObject("total_maxdd");
    double cash = jo.get("cash").getAsDouble();
    double pct = jo.get("pct").getAsDouble();
    message += "\n" + "Total equity peak [" + dateStr + "]: " + String.format("$%,d", maxEndEq) + "\n"
            + String.format("Current Drawdown: $%,d [%.2f%%]", Math.round(cash), pct) + "\n";

    if (report.has("latest_peak") && report.has("latest_maxdd")) {
        jo = report.getAsJsonObject("latest_peak");
        LocalDate ld = LocalDate.parse(jo.get("date").getAsString(), DateTimeFormatter.ISO_DATE);
        maxEndEq = jo.get("equity").getAsInt();
        jo = report.getAsJsonObject("latest_maxdd");
        cash = jo.get("cash").getAsDouble();
        pct = jo.get("pct").getAsDouble();
        message += "\n" + Integer.toString(ld.getYear()) + " equity peak ["
                + ld.format(DateTimeFormatter.ISO_DATE) + "]: " + String.format("$%,d", maxEndEq) + "\n"
                + String.format("Current Drawdown: $%,d [%.2f%%]", Math.round(cash), pct) + "\n";
    }

    message += "\n" + "Avg Trade PnL: "
            + String.format("$%,d", Math.round(report.get("avg_trade_pnl").getAsDouble())) + ", Max DD: "
            + String.format("$%,d", Math.round(report.get("maxdd").getAsDouble())) + ", Max DD Pct: "
            + String.format("%.2f%%", report.get("maxdd_pct").getAsDouble()) + ", Num Trades: "
            + Integer.toString(report.get("num_trades").getAsInt());

    System.out.println(message);

    if (actionsFile != null) {
        FileUtils.writeStringToFile(actionsFile, message + System.getProperty("line.separator"), true);
    }

    if (Boolean.parseBoolean(BacktestCfg.instance().getProperty("email.enabled", "false"))) {
        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "smtp.sendgrid.net");
        props.put("mail.smtp.port", "587");

        String user = BacktestCfg.instance().getProperty("email.user");
        String pass = BacktestCfg.instance().getProperty("email.pass");

        Session session = Session.getInstance(props, new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(user, pass);
            }
        });

        MimeMessage msg = new MimeMessage(session);
        try {
            msg.setFrom(new InternetAddress(BacktestCfg.instance().getProperty("email.from")));
            msg.addRecipients(RecipientType.TO, BacktestCfg.instance().getProperty("email.recipients"));
            msg.setSubject(strategy.getName() + " Report ["
                    + strategy.getLastTimestamp().format(DateTimeFormatter.ISO_LOCAL_DATE) + "]");
            msg.setText("Positions & Signals\n" + signalText + "\n\nStatistics\n" + message);
            Transport.send(msg);
        } catch (Exception ee) {
            Logger.getLogger("").warning(ee.getMessage());
        }
    }

    if (Boolean.parseBoolean(BacktestCfg.instance().getProperty("sftp.enabled", "false"))) {
        HashMap<String, String> fileMap = new HashMap<String, String>();
        if (!Strings.isNullOrEmpty(actionsPath))
            fileMap.put(actionsPath, actionsPath);
        if (!Strings.isNullOrEmpty(ordersCsvPath))
            fileMap.put(ordersCsvPath, ordersCsvPath);
        String user = BacktestCfg.instance().getProperty("sftp.user");
        String pass = BacktestCfg.instance().getProperty("sftp.pass");
        String host = BacktestCfg.instance().getProperty("sftp.host");
        SftpUploader sftp = new SftpUploader(host, user, pass);
        sftp.upload(fileMap);
    }
}

From source file:com.sencko.basketball.stats.advanced.FIBAJsonParser.java

private static Game readGameFromNet(String location) throws IOException, MalformedURLException {
    InputStream jsonInputStream;//from  w  w w .  jav  a2 s  . c  o  m
    String prefix = "http://webcast-a.live.sportingpulseinternational.com/matches/";
    String suffix = "//data.json";
    String html_suffix = "//index.html";
    URL url = new URL(prefix + location + suffix);

    logger.log(Level.FINEST, "Downloading file {0} from internet", url.toString());
    URLConnection connection = url.openConnection();
    connection.connect();
    jsonInputStream = connection.getInputStream();

    try {
        Game game = readGameFromStream(jsonInputStream);
        try {
            URL html_url = new URL(prefix + location + html_suffix);
            String html = IOUtils.toString(html_url, "UTF-8");
            Matcher match = teamAndTime.matcher(html);
            if (match.matches()) {

                game.getTm().get(1).setTeam(match.group(1));
                game.getTm().get(2).setTeam(match.group(2));
                Calendar calendar = Calendar.getInstance(); //TimeZone.getTimeZone("EET")
                calendar.set(Integer.parseInt(match.group(7)), Integer.parseInt(match.group(6)) - 1,
                        Integer.parseInt(match.group(5)), Integer.parseInt(match.group(3)),
                        Integer.parseInt(match.group(4)));
                game.setDate(calendar.getTime());

            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return game;
    } finally {
        jsonInputStream.close();
    }
}

From source file:de.hofuniversity.iisys.neo4j.websock.query.encoding.safe.TSafeJsonQueryHandler.java

public TSafeJsonQueryHandler() {
    fLogger = Logger.getLogger(this.getClass().getName());
    fDebug = (fLogger.getLevel() == Level.FINEST);
}

From source file:com.agiletec.aps.util.ForJLogger.java

public boolean isTraceEnabled() {
    return _log.isLoggable(Level.FINEST);
}