Example usage for java.util.logging Level FINE

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

Introduction

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

Prototype

Level FINE

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

Click Source Link

Document

FINE is a message level providing tracing information.

Usage

From source file:com.twitter.heron.scheduler.RuntimeManagerMain.java

public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException,
        InstantiationException, IOException, ParseException {

    Options options = constructOptions();
    Options helpOptions = constructHelpOptions();
    CommandLineParser parser = new DefaultParser();
    // parse the help options first.
    CommandLine cmd = parser.parse(helpOptions, args, true);

    if (cmd.hasOption("h")) {
        usage(options);/* w  w  w  .  j a v a 2 s .co  m*/
        return;
    }

    try {
        // Now parse the required options
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        usage(options);
        throw new RuntimeException("Error parsing command line options: ", e);
    }

    Boolean verbose = false;
    Level logLevel = Level.INFO;
    if (cmd.hasOption("v")) {
        logLevel = Level.ALL;
        verbose = true;
    }

    // init log
    LoggingHelper.loggerInit(logLevel, false);

    String cluster = cmd.getOptionValue("cluster");
    String role = cmd.getOptionValue("role");
    String environ = cmd.getOptionValue("environment");
    String heronHome = cmd.getOptionValue("heron_home");
    String configPath = cmd.getOptionValue("config_path");
    String overrideConfigFile = cmd.getOptionValue("override_config_file");
    String releaseFile = cmd.getOptionValue("release_file");
    String topologyName = cmd.getOptionValue("topology_name");
    String commandOption = cmd.getOptionValue("command");

    // Optional argument in the case of restart
    // TODO(karthik): convert into CLI
    String containerId = Integer.toString(-1);
    if (cmd.hasOption("container_id")) {
        containerId = cmd.getOptionValue("container_id");
    }

    Command command = Command.makeCommand(commandOption);

    // first load the defaults, then the config from files to override it
    Config.Builder defaultsConfig = Config.newBuilder().putAll(ClusterDefaults.getDefaults())
            .putAll(ClusterConfig.loadConfig(heronHome, configPath, releaseFile));

    // add config parameters from the command line
    Config.Builder commandLineConfig = Config.newBuilder().put(Keys.cluster(), cluster).put(Keys.role(), role)
            .put(Keys.environ(), environ).put(Keys.verbose(), verbose)
            .put(Keys.topologyContainerId(), containerId);

    Config.Builder topologyConfig = Config.newBuilder().put(Keys.topologyName(), topologyName);

    Config.Builder overrideConfig = Config.newBuilder()
            .putAll(ClusterConfig.loadOverrideConfig(overrideConfigFile));

    // build the final config by expanding all the variables
    Config config = Config
            .expand(Config.newBuilder().putAll(defaultsConfig.build()).putAll(overrideConfig.build())
                    .putAll(commandLineConfig.build()).putAll(topologyConfig.build()).build());

    LOG.fine("Static config loaded successfully ");
    LOG.fine(config.toString());

    // Create a new instance of RuntimeManagerMain
    RuntimeManagerMain runtimeManagerMain = new RuntimeManagerMain(config, command);
    boolean isSuccessful = runtimeManagerMain.manageTopology();

    // Log the result and exit
    if (!isSuccessful) {
        throw new RuntimeException(String.format("Failed to %s topology %s", command, topologyName));
    } else {
        LOG.log(Level.FINE, "Topology {0} {1} successfully", new Object[] { topologyName, command });
    }
}

From source file:dk.hippogrif.prettyxml.app.Main.java

/**
 * Application using commandline options or running GUI if no options.
 *//*from   w  ww.ja va2s . c o m*/
public static void main(String[] args) {
    try {
        PrettyPrint prettyPrint = new PrettyPrint();
        version = prettyPrint.getVersion();
        if (args.length == 0) {
            MainJFrame.run(version);
        } else {
            go(args);
        }
    } catch (Exception e) {
        logger.log(Level.FINE, "main", e);
        System.err.println(e.getMessage());
    }
}

From source file:com.ibm.cics.ca1y.Emit.java

/**
 * Format a request from the JVM standard in and command line arguments. Each line in standard in, or argument on
 * the command line should follow the conventions required to be loaded by the Java Properties class, eg. name=value
 * /*from w w w  .j  a va  2 s. c o m*/
 * @param args
 *            - zero or more arguments specified on the command line
 * @return exit code - 0 if successfull, non-zero if there was at least one problem actioning the request
 */
public static void main(String[] args) {
    if (logger.isLoggable(Level.FINE)) {
        logger.fine(messages.getString("EmitStart"));
    }

    EmitProperties props = new EmitProperties();

    addPropertiesFromInputStream(props, System.in);

    addPropertiesFromString(props, args);

    boolean returnCode = Emit.emit(props, null, false);

    if (logger.isLoggable(Level.FINE)) {
        logger.fine(messages.getString("EmitFinish"));
    }

    System.exit(returnCode ? 0 : 8);
}

From source file:com.twitter.heron.scheduler.SubmitterMain.java

public static void main(String[] args) throws Exception {
    Options options = constructOptions();
    Options helpOptions = constructHelpOptions();
    CommandLineParser parser = new DefaultParser();
    // parse the help options first.
    CommandLine cmd = parser.parse(helpOptions, args, true);

    if (cmd.hasOption("h")) {
        usage(options);/*from   w ww  .  ja v  a  2 s .c  o m*/
        return;
    }

    try {
        // Now parse the required options
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        usage(options);
        throw new RuntimeException("Error parsing command line options: ", e);
    }

    Boolean verbose = false;
    Level logLevel = Level.INFO;
    if (cmd.hasOption("v")) {
        logLevel = Level.ALL;
        verbose = true;
    }

    // init log
    LoggingHelper.loggerInit(logLevel, false);

    String cluster = cmd.getOptionValue("cluster");
    String role = cmd.getOptionValue("role");
    String environ = cmd.getOptionValue("environment");
    String heronHome = cmd.getOptionValue("heron_home");
    String configPath = cmd.getOptionValue("config_path");
    String overrideConfigFile = cmd.getOptionValue("override_config_file");
    String releaseFile = cmd.getOptionValue("release_file");
    String topologyPackage = cmd.getOptionValue("topology_package");
    String topologyDefnFile = cmd.getOptionValue("topology_defn");
    String topologyJarFile = cmd.getOptionValue("topology_jar");

    // load the topology definition into topology proto
    TopologyAPI.Topology topology = TopologyUtils.getTopology(topologyDefnFile);

    // first load the defaults, then the config from files to override it
    // next add config parameters from the command line
    // load the topology configs

    // build the final config by expanding all the variables
    Config config = Config.expand(Config.newBuilder().putAll(defaultConfigs(heronHome, configPath, releaseFile))
            .putAll(overrideConfigs(overrideConfigFile))
            .putAll(commandLineConfigs(cluster, role, environ, verbose))
            .putAll(topologyConfigs(topologyPackage, topologyJarFile, topologyDefnFile, topology)).build());

    LOG.fine("Static config loaded successfully ");
    LOG.fine(config.toString());

    SubmitterMain submitterMain = new SubmitterMain(config, topology);
    boolean isSuccessful = submitterMain.submitTopology();

    // Log the result and exit
    if (!isSuccessful) {
        throw new RuntimeException(String.format("Failed to submit topology %s", topology.getName()));
    } else {
        LOG.log(Level.FINE, "Topology {0} submitted successfully", topology.getName());
    }
}

From source file:com.ibm.cics.ca1y.Emit.java

public static void main(CommAreaHolder commAreaHolder) {
    if (logger.isLoggable(Level.FINE)) {
        logger.fine(messages.getString("EmitStart") + " " + messages.getString("Name") + " "
                + messages.getString("Version") + " " + messages.getString("Copyright"));
    }// www . ja  v  a2 s.c  o m

    Channel channel = Task.getTask().getCurrentChannel();
    if (channel == null) {
        try {
            // Create channel in case it is needed later for linking to other CICS programs
            channel = Task.getTask().createChannel(CA1Y_CHANNEL);

        } catch (ChannelErrorException e) {
            logger.warning(messages.getString("CouldNotCreateChannelCA1Y"));
            e.printStackTrace();

            // As there is no CICS channel, cannot return an error container, so perform a CICS ABEND
            Task.getTask().abend(CA1Y_ABEND_CODE);
        }
    }

    if (logger.isLoggable(Level.FINE)) {
        logger.fine(messages.getString("EmitStartChannel") + " " + channel.getName());
    }

    boolean isStartedWithEPAdpter = false;
    boolean isStartedWithCommarea = false;
    boolean isStartedWithCA1YContainer = false;
    EmitProperties props = new EmitProperties();

    if ((channel.getName().startsWith("DFHEP.")) || (channel.getName().startsWith("DFHMP."))) {
        // Configuration is passed as an event adapter container.
        //
        // A CICS event from an event binding is passed in a channel name
        // starting with 'DFHEP.'.
        // A CICS event from a policy is passed in a channel name starting with 'DFHMP.'.

        // Avoid having to make this test again by keeping a cache
        isStartedWithEPAdpter = true;

        if (addContainerDFHEP_ADAPTER(props, channel) == false) {
            logger.warning(messages.getString("MissingContainerDfhepAdapter"));

            putContainerCA1YRESPONSE(false, channel);
            return;
        }

    } else if ((commAreaHolder != null) && (commAreaHolder.getValue().length > 0)) {
        // Configuration is passed in a CICS commarea
        isStartedWithCommarea = true;

        addCommarea(props, commAreaHolder);

    } else if (Task.getTask().getSTARTCODE().equals("SD")) {
        // Configuration is passed in the CICS start data
        addRetrieveData(props);

    } else {
        // Configuration is passed in a CICS container named CA1Y
        isStartedWithCA1YContainer = true;

        if (addContainerCA1Y(props, channel) == false) {
            logger.warning(messages.getString("MissingContainerCA1Y"));

            putContainerCA1YRESPONSE(false, channel);
            return;
        }
    }

    if (isStartedWithEPAdpter == false) {
        addPropertiesFromTask(props, Task.getTask());
        addPropertiesFromCICSRegion(props);
    }

    boolean emissionSuccessful = emit(props, channel, isStartedWithEPAdpter);

    // Create a response container for each property that needs to be returned
    for (Map.Entry<String, String> entry : props.getReturnContainers().entrySet()) {
        if (logger.isLoggable(Level.FINE)) {
            logger.fine(messages.getString("CreateResponseContainer") + " "
                    + EmitProperties.getPropertySummary(props, entry.getKey()));
        }

        try {
            Container container = channel.createContainer(entry.getValue());

            if (props.getPropertyAttachment(entry.getKey()) == null) {
                // Create a container of type CHAR
                container.putString(props.getProperty(entry.getKey()));

            } else {
                // Creates a container of type BIT
                container.put(props.getPropertyAttachment(entry.getKey()));
            }

        } catch (Exception e) {
            logger.fine(messages.getString("FailedToCreateResponseContainer") + " " + entry.getValue());
            e.printStackTrace();
            emissionSuccessful = false;
        }
    }

    if ((emissionSuccessful == false) && (props.containsKey(ONFAILURE))) {
        // Link to onfailure program
        String onfailure = props.getProperty(ONFAILURE).trim();

        if (logger.isLoggable(Level.FINE)) {
            logger.fine(messages.getString("LinkToOnfailure") + " " + onfailure);
        }

        Program p = new Program();
        p.setName(onfailure);

        try {
            p.link(channel);

            // As we successfully called the specified program to handle the failure, treat this as a successful
            // emission
            emissionSuccessful = true;

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (logger.isLoggable(Level.FINE)) {
        logger.fine(messages.getString("EmitFinish") + " " + messages.getString("Name") + " "
                + messages.getString("Version") + " " + messages.getString("Copyright"));

    }

    if (isStartedWithEPAdpter) {
        if (emissionSuccessful == false) {
            // CICS event processing expects the adapter to issue a CICS abend if the event could not be emitted to
            // update CICS statistics
            Task.getTask().abend(CA1Y_ABEND_CODE);
        }

    } else if (isStartedWithCA1YContainer) {
        putContainerCA1YRESPONSE(emissionSuccessful, channel);

    } else if (isStartedWithCommarea) {
        putCommarea(emissionSuccessful, commAreaHolder);
    }
}

From source file:cz.cas.lib.proarc.common.export.cejsh.CejshConfig.java

public static CejshConfig from(Configuration conf) {
    CejshConfig cc = new CejshConfig();
    cc.setCejshXslUrl(conf.getString(PROP_MODS_XSL_URL, null));
    //        cc.setJournalUrl(conf.getString(PROP_JOURNALS_URL, null));
    try {//from w w w .ja va  2 s.  c  o m
        boolean debug = conf.getBoolean(PROP_DEBUG, Boolean.FALSE);
        cc.setLogLevel(debug ? Level.INFO : Level.FINE);
    } catch (ConversionException ex) {
        LOG.log(Level.SEVERE, PROP_DEBUG, ex);
    }
    return cc;
}

From source file:net.oneandone.sushi.fs.webdav.WebdavFilesystem.java

public static void wireLog(String file) {
    Handler handler;//w  ww  .ja  v  a  2  s  .  c o  m

    WIRE.setLevel(Level.FINE);
    try {
        handler = new FileHandler(file, false);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    handler.setFormatter(new Formatter() {
        @Override
        public String format(LogRecord record) {
            String message;
            Throwable e;
            StringBuilder result;

            message = record.getMessage();
            result = new StringBuilder(message.length() + 1);
            result.append(message);
            result.append('\n');
            e = record.getThrown();
            if (e != null) {
                // TODO getStacktrace(e, result);
            }
            return result.toString();
        }
    });

    WIRE.addHandler(handler);
}

From source file:com.qualogy.qafe.bind.core.application.io.ResourceMerger.java

@SuppressWarnings("unchecked")
public static ApplicationMapping merge(Class mergeableClassName, List<ApplicationMapping> concreteMappings,
        List<FileLocation> fileLocations, String appName, String root, boolean autoScanRoot,
        boolean recursiveScan, boolean validating) {

    logger.log(Level.FINE, "Start merging application mappings for application [{0}]", appName);

    ApplicationMapping applicationMapping = null;

    //boolean to see whether a concrete and/or location is/are set
    boolean noMappings = ((concreteMappings == null || concreteMappings.isEmpty())
            && (fileLocations == null || fileLocations.isEmpty()));

    ByteArrayInputStream in = null;
    try {//ww w  .j  a  va2  s. com

        if (concreteMappings != null) {
            for (ApplicationMapping mapping : concreteMappings) {
                if (applicationMapping != null)
                    throw new LoadFailedException(appName,
                            "loading two application-mappings through application-context without resource is not yet supported");
                if ((fileLocations == null || fileLocations.isEmpty())) {
                    applicationMapping = mapping;
                } else {
                    ByteArrayOutputStream out = null;
                    try {
                        out = new ByteArrayOutputStream();
                        new Writer().write(mapping, out, false);
                        byte[] bytes = out.toByteArray();
                        in = new ByteArrayInputStream(bytes);
                    } finally {
                        if (out != null)
                            try {
                                out.close();
                            } catch (IOException e) {
                                logger.log(Level.SEVERE,
                                        "Error occured while closing outputstream for application: " + appName,
                                        e);
                            }
                    }
                }
            }
        }

        if (noMappings || fileLocations != null) {
            List<URI> filePaths = new ArrayList<URI>();
            if (noMappings && autoScanRoot) {
                logger.warning("No application-mapping found for context, using root [" + root
                        + "] to scan for application-mapping (since auto-scan-root is set to true)");
                filePaths.add(new FileLocation(root, "").toURI());
            } else if (noMappings && !autoScanRoot) {
                throw new LoadFailedException(appName,
                        "No application-mapping found and auto-scan is false (default), cannot startup without application-mapping");
            } else if (fileLocations != null) {
                for (FileLocation location : fileLocations) {
                    location.setRoot(root);
                    URI path = location.toURI();
                    if (path == null)
                        throw new BindException(
                                "No file found at mapping file location [" + location.toString() + "]");
                    filePaths.add(path);
                }
            }

            logger.info("Start reading application mappings for application [" + appName + "] from ["
                    + filePaths + "]");

            try {
                applicationMapping = (ApplicationMapping) new Reader(ApplicationMapping.class).read(in,
                        filePaths, root, recursiveScan);
            } catch (RuntimeException e) {
                String message = e != null ? e.getMessage() : null;
                throw new LoadFailedException(appName, message, e);
            }

            logger.info("Finished reading application mappings for application [" + appName + "]");
        }
    } finally {
        try {
            if (in != null)
                in.close();
        } catch (IOException e) {
            logger.log(Level.SEVERE, "Error occured while closing inputstream", e);
        }
    }

    return applicationMapping;
}

From source file:net.daboross.bukkitdev.skywars.gist.GistReport.java

public static String gistText(Logger logger, String text) {
    URL postUrl;/* w w  w  .  j  av  a2 s .c o  m*/
    try {
        postUrl = new URL("https://api.github.com/gists");
    } catch (MalformedURLException ex) {
        logger.log(Level.FINE, "Non severe error encoding api.github.com URL", ex);
        return null;
    }
    URLConnection connection;
    try {
        connection = postUrl.openConnection();
    } catch (IOException ex) {
        logger.log(Level.FINE, "Non severe error opening api.github.com connection", ex);
        return null;
    }
    connection.setDoOutput(true);
    connection.setDoInput(true);
    JSONStringer outputJson = new JSONStringer();
    try {
        outputJson.object().key("description").value("SkyWars debug").key("public").value("false").key("files")
                .object().key("report.md").object().key("content").value(text).endObject().endObject()
                .endObject();
    } catch (JSONException ex) {
        logger.log(Level.FINE, "Non severe error while writing report", ex);
        return null;
    }
    String jsonOuptutString = outputJson.toString();
    try (OutputStream outputStream = connection.getOutputStream()) {
        try (OutputStreamWriter requestWriter = new OutputStreamWriter(outputStream)) {
            requestWriter.append(jsonOuptutString);
            requestWriter.close();
        }
    } catch (IOException ex) {
        logger.log(Level.FINE, "Non severe error writing report", ex);
        return null;
    }

    JSONObject inputJson;
    try {
        inputJson = new JSONObject(readConnection(connection));
    } catch (JSONException | IOException unused) {
        logger.log(Level.FINE, "Non severe error while reading response for report.", unused);
        return null;
    }
    String resultUrl = inputJson.optString("html_url", null);
    return resultUrl == null ? null : shortenURL(logger, resultUrl);
}

From source file:onl.area51.filesystem.http.client.HttpUtils.java

public static void retrieve(char[] path, Function<char[], String> remoteUri, Supplier<FileSystemIO> delegate,
        Supplier<String> userAgent) throws IOException {
    if (path == null || path.length == 0) {
        throw new FileNotFoundException("/");
    }/*from  w w  w. java2s  .  c om*/

    String uri = remoteUri.apply(path);
    if (uri != null) {

        LOG.log(Level.FINE, () -> "Retrieving " + uri);

        HttpGet get = new HttpGet(uri);
        get.setHeader(USER_AGENT, userAgent.get());

        try (CloseableHttpClient client = HttpClients.createDefault()) {
            try (CloseableHttpResponse response = client.execute(get)) {

                int returnCode = response.getStatusLine().getStatusCode();
                LOG.log(Level.FINE,
                        () -> "ReturnCode " + returnCode + ": " + response.getStatusLine().getReasonPhrase());

                switch (returnCode) {
                case 200:
                case 304:
                    FileSystemUtils.copyFromRemote(() -> response.getEntity().getContent(), delegate.get(),
                            path);
                    return;

                default:
                }
            }
        }
    }

    throw new FileNotFoundException(String.valueOf(path));
}