Example usage for java.util.logging ConsoleHandler setLevel

List of usage examples for java.util.logging ConsoleHandler setLevel

Introduction

In this page you can find the example usage for java.util.logging ConsoleHandler setLevel.

Prototype

public synchronized void setLevel(Level newLevel) throws SecurityException 

Source Link

Document

Set the log level specifying which message levels will be logged by this Handler .

Usage

From source file:com.freesundance.contacts.google.ContactsExample.java

/**
 * Run the example program.//from w w w .  j  av a  2s. c  o m
 *
 * @param args Command-line arguments.
 */
public static void main(String[] args) throws ServiceException, IOException, GeneralSecurityException {

    ContactsExampleParameters parameters = new ContactsExampleParameters(args);
    if (parameters.isVerbose()) {
        httpRequestLogger.setLevel(Level.FINEST);
        ConsoleHandler handler = new ConsoleHandler();
        handler.setLevel(Level.FINEST);
        httpRequestLogger.addHandler(handler);
        httpRequestLogger.setUseParentHandlers(false);
    }

    if (parameters.numberOfParameters() == 0 || parameters.isHelp()
            || (parameters.getAction() == null && parameters.getScript() == null)) {
        displayUsage();
        return;
    }

    // Check that at most one of contactfeed and groupfeed has been provided
    if (parameters.isContactFeed() && parameters.isGroupFeed()) {
        throw new RuntimeException("Only one of contactfeed / groupfeed should" + "be specified");
    }

    ContactsExample example = new ContactsExample(parameters);

    processAction(example, parameters);
    System.out.flush();
}

From source file:lineage.LineageEngine.java

public static void main(String[] args) {
    Options options = new Options();
    // Commands//  ww  w .ja va2  s .c o m
    options.addOption("build", false, "Construct the sample lineage trees");

    // Input/Output/Display
    options.addOption("i", true, "Input file path [required]");
    options.addOption("o", true, "Output file path (default: input file with suffix .trees.txt)");
    options.addOption("cp", false, "Input data represents cell prevalaence (CP) values");
    options.addOption("sampleProfile", false,
            "Input file contains the SSNV sample presence-absence profile (this will disable the default SSNV calling step)");
    options.addOption("n", "normal", true,
            "Normal sample column id in the list of samples, 0-based (e.g 0 is the first column) [required without -sampleProfile]");
    options.addOption("clustersFile", true, "SSNV clusters file path");
    options.addOption("s", "save", true, "Maximum number of output trees to save (default: 1)");
    options.addOption("showNetwork", "net", false, "Display the constraint network");
    options.addOption("showTree", "tree", true, "Number of top-ranking trees to display (default: 0)");

    // SSNV filtering / calling
    options.addOption("maxVAFAbsent", "absent", true,
            "Maximum VAF to robustly consider an SSNV as absent from a sample [required without -sampleProfile]");
    options.addOption("minVAFPresent", "present", true,
            "Minimum VAF to robustly consider an SSNV as present in a sample [required without -sampleProfile]");
    options.addOption("maxVAFValid", true, "Maximum allowed VAF in a sample (default: 0.6)");
    options.addOption("minProfileSupport", true,
            "Minimum number of robust SSNVs required for a group presence-absence profile to be labeled robust (default: 2)");

    // Network Construction / Tree Search
    options.addOption("minClusterSize", true,
            "Minimum size a cluster must have to be a considered a node in the network (default: 2)");
    options.addOption("minPrivateClusterSize", true,
            "Minimum size a private mutation cluster must have to be a considered a node in the network (default: 1)");
    options.addOption("minRobustNodeSupport", true,
            "Minimum number of robust SSNVs required for a node to be labeled robust during tree search: non-robust nodes can be removed from the network when no valid lineage trees are found (default: 2)");
    options.addOption("maxClusterDist", true,
            "Maximum mean VAF difference up to which two clusters can be collapsed (default: 0.2)");
    options.addOption("c", "completeNetwork", false,
            "Add all possible edges to the constraint network (default: private nodes are connected only to closest level parents; only nodes with no other parents are descendants of root)");
    options.addOption("e", true, "VAF error margin (default: 0.1)");
    options.addOption("nTreeQPCheck", true,
            "Number of top-ranking trees on which the QP consistency check is run, we have not seen this check fail in practice (default: 0, for best performance)");

    options.addOption("v", "verbose", false, "Verbose mode");
    options.addOption("h", "help", false, "Print usage");

    // display order
    ArrayList<Option> optionsList = new ArrayList<Option>();
    optionsList.add(options.getOption("build"));

    optionsList.add(options.getOption("i"));
    optionsList.add(options.getOption("o"));
    optionsList.add(options.getOption("cp"));
    optionsList.add(options.getOption("sampleProfile"));
    optionsList.add(options.getOption("n"));
    optionsList.add(options.getOption("clustersFile"));
    optionsList.add(options.getOption("s"));
    optionsList.add(options.getOption("net"));
    optionsList.add(options.getOption("tree"));
    optionsList.add(options.getOption("maxVAFAbsent"));
    optionsList.add(options.getOption("minVAFPresent"));
    optionsList.add(options.getOption("maxVAFValid"));
    optionsList.add(options.getOption("minProfileSupport"));
    optionsList.add(options.getOption("minClusterSize"));
    optionsList.add(options.getOption("minPrivateClusterSize"));
    optionsList.add(options.getOption("minRobustNodeSupport"));
    optionsList.add(options.getOption("maxClusterDist"));
    optionsList.add(options.getOption("c"));
    optionsList.add(options.getOption("e"));
    optionsList.add(options.getOption("nTreeQPCheck"));
    optionsList.add(options.getOption("v"));
    optionsList.add(options.getOption("h"));

    CommandLineParser parser = new BasicParser();
    CommandLine cmdLine = null;
    HelpFormatter hf = new HelpFormatter();
    hf.setOptionComparator(new OptionComarator<Option>(optionsList));
    try {
        cmdLine = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        hf.printHelp("lichee", options);
        System.exit(-1);
    }

    // Set-up input args
    Args params = new Args();
    if (cmdLine.hasOption("i")) {
        params.inputFileName = cmdLine.getOptionValue("i");
    } else {
        System.out.println("Required parameter: input file path [-i]");
        hf.printHelp("lichee", options);
        System.exit(-1);
    }
    if (cmdLine.hasOption("o")) {
        params.outputFileName = cmdLine.getOptionValue("o");
    } else {
        params.outputFileName = params.inputFileName + TREES_TXT_FILE_EXTENSION;
    }
    if (cmdLine.hasOption("clustersFile")) {
        params.clustersFileName = cmdLine.getOptionValue("clustersFile");
    }
    if (cmdLine.hasOption("sampleProfile")) {
        Parameters.INPUT_FORMAT = Format.SNV_WITH_PROFILE;
    }

    if (cmdLine.hasOption("n")) {
        params.normalSampleId = Integer.parseInt(cmdLine.getOptionValue("n"));
    } else if (!cmdLine.hasOption("sampleProfile")) {
        System.out.println("Required parameter: normal sample id [-n]");
        hf.printHelp("lichee", options);
        System.exit(-1);
    }
    if (cmdLine.hasOption("showTree")) {
        params.numShow = Integer.parseInt(cmdLine.getOptionValue("showTree"));
    }
    if (cmdLine.hasOption("showNetwork")) {
        params.showNetwork = true;
    }
    if (cmdLine.hasOption("s")) {
        params.numSave = Integer.parseInt(cmdLine.getOptionValue("s"));
    }

    if (cmdLine.hasOption("maxVAFAbsent")) {
        Parameters.MAX_VAF_ABSENT = Double.parseDouble(cmdLine.getOptionValue("maxVAFAbsent"));
    } else if (!cmdLine.hasOption("sampleProfile")) {
        System.out.println("Required parameter: -maxVAFAbsent");
        hf.printHelp("lichee", options);
        System.exit(-1);
    }
    if (cmdLine.hasOption("minVAFPresent")) {
        Parameters.MIN_VAF_PRESENT = Double.parseDouble(cmdLine.getOptionValue("minVAFPresent"));
    } else if (!cmdLine.hasOption("sampleProfile")) {
        System.out.println("Required parameter: -minVAFPresent");
        hf.printHelp("lichee", options);
        System.exit(-1);
    }
    if (cmdLine.hasOption("maxVAFValid")) {
        Parameters.MAX_ALLOWED_VAF = Double.parseDouble(cmdLine.getOptionValue("maxVAFValid"));
    }
    if (cmdLine.hasOption("minProfileSupport")) {
        Parameters.MIN_GROUP_PROFILE_SUPPORT = Integer.parseInt(cmdLine.getOptionValue("minProfileSupport"));
    }
    if (cmdLine.hasOption("minClusterSize")) {
        Parameters.MIN_CLUSTER_SIZE = Integer.parseInt(cmdLine.getOptionValue("minClusterSize"));
    }
    if (cmdLine.hasOption("minPrivateClusterSize")) {
        Parameters.MIN_PRIVATE_CLUSTER_SIZE = Integer.parseInt(cmdLine.getOptionValue("minPrivateClusterSize"));
    }
    if (cmdLine.hasOption("minRobustNodeSupport")) {
        Parameters.MIN_ROBUST_CLUSTER_SUPPORT = Integer
                .parseInt(cmdLine.getOptionValue("minRobustNodeSupport"));
    }
    if (cmdLine.hasOption("maxClusterDist")) {
        Parameters.MAX_COLLAPSE_CLUSTER_DIFF = Double.parseDouble(cmdLine.getOptionValue("maxClusterDist"));
    }
    if (cmdLine.hasOption("c")) {
        Parameters.ALL_EDGES = true;
    }
    if (cmdLine.hasOption("cp")) {
        Parameters.CP = true;
        Parameters.VAF_MAX = 1.0;
        Parameters.MAX_ALLOWED_VAF = 1.0;
    }
    if (cmdLine.hasOption("e")) {
        Parameters.VAF_ERROR_MARGIN = Double.parseDouble(cmdLine.getOptionValue("e"));
    }
    if (cmdLine.hasOption("nTreeQPCheck")) {
        Parameters.NUM_TREES_FOR_CONSISTENCY_CHECK = Integer.parseInt(cmdLine.getOptionValue("nTreeQPCheck"));
    }
    if (cmdLine.hasOption("h")) {
        new HelpFormatter().printHelp(" ", options);
    }
    // logger
    ConsoleHandler h = new ConsoleHandler();
    h.setFormatter(new LogFormatter());
    h.setLevel(Level.INFO);
    logger.setLevel(Level.INFO);
    if (cmdLine.hasOption("v")) {
        h.setLevel(Level.FINEST);
        logger.setLevel(Level.FINEST);
    }
    logger.addHandler(h);
    logger.setUseParentHandlers(false);

    if (cmdLine.hasOption("build")) {
        buildLineage(params);

    } else {
        new HelpFormatter().printHelp("lichee", options);
        System.exit(-1);
    }
}

From source file:LineageSimulator.java

public static void main(String[] args) {
    Options options = new Options();
    // commands/*w  ww .j  a va 2s .co  m*/
    //options.addOption("simulate", false, "Simulate lineage trees");
    //options.addOption("sample", false, "Sample from the simulated trees");
    //options.addOption("evaluate", false, "Evaluate trees");

    // tree simulation
    options.addOption("t", "nTrees", true, "Number of trees to simulate (default: 100)");
    options.addOption("i", "nIter", true, "Number of tree growth iterations (default: 50)");
    options.addOption("snv", "probSNV", true,
            "Per node probablity of generating a descendant cell population with an acquired SNV during a tree growth iteration (default: 0.15)");
    options.addOption("cnv", "probCNV", true,
            "Per node probablity of generating a descendant cell population with an acquired CNV during a tree growth iteration (default: 0.02)");
    options.addOption("probDeath", true,
            "Probablity of a cell population death in each tree growth iteration (default: 0.06)");
    options.addOption("maxPopulationSize", true, "Max size of a cell population (default: 1000000)");
    options.addOption("minNodes", true,
            "Minimum number of undead cell population nodes in a valid tree, tree growth will continue beyond the defined number of iterations until this value is reached (default: 10)");
    options.addOption("maxNodes", true,
            "Maximum number of undead cell population nodes in a tree, tree growth will stop after the iteration in which this value is reached/first surpassed (default: 1000)");

    // sampling
    Option samplesOption = new Option("s", "nSamples", true,
            "Number of samples to collect, accepts multiple values, e.g. 5 10 15 (default: 5)");
    samplesOption.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(samplesOption);
    Option covOption = new Option("c", "coverage", true,
            "Simulated coverage to generate the VAFs, accepts multiple values, e.g. 500 1000 (default: 1000)");
    covOption.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(covOption);
    options.addOption("maxSubclones", true, "Max number of subclones per sample (default: 5)");
    options.addOption("sampleSize", true, "Number of cells per sample (default: 100000)");
    options.addOption("e", true, "Sequencing error (default: 0.001)");
    options.addOption("minNC", true,
            "Minimum percentage of normal contamination per sample; the percentage will be randomly generated from the range [minNC maxNC] for each sample (default: 0)");
    options.addOption("maxNC", true,
            "Maximum percentage of normal contamination per sample; if maxNC < minNC, maxNC will be automatically set to minNC; the percentage will be randomly generated from the range [minNC maxNC] for each sample (default: 20)");
    //options.addOption("localized", false, "Enable localized sampling (default: random sampling)");
    //options.addOption("mixSubclone", false, "With localized sampling, add an additional subclone from a different subtree to each sample; by default, the sample is localized to a single disjoint subtree");

    // input/output/display
    options.addOption("dir", "outputDir", true,
            "Directory where the output files should be created [required]");
    options.addOption("dot", false, "Produce DOT files for the simulated trees");
    options.addOption("sdot", "sampledDot", false,
            "Produce DOT files for the simulated trees with indicated samples");
    options.addOption("sampleProfile", false,
            "Output VAF file includes an additional column with the binary sample profile for each SNV");

    // other
    options.addOption("v", "verbose", false, "Verbose mode");
    options.addOption("h", "help", false, "Print usage");

    // display order
    ArrayList<Option> optionsList = new ArrayList<Option>();
    optionsList.add(options.getOption("dir"));
    optionsList.add(options.getOption("t"));
    optionsList.add(options.getOption("i"));
    optionsList.add(options.getOption("snv"));
    optionsList.add(options.getOption("cnv"));
    optionsList.add(options.getOption("probDeath"));
    optionsList.add(options.getOption("maxPopulationSize"));
    optionsList.add(options.getOption("minNodes"));
    optionsList.add(options.getOption("maxNodes"));
    optionsList.add(options.getOption("s"));
    optionsList.add(options.getOption("c"));
    optionsList.add(options.getOption("maxSubclones"));
    optionsList.add(options.getOption("sampleSize"));
    optionsList.add(options.getOption("e"));
    optionsList.add(options.getOption("minNC"));
    optionsList.add(options.getOption("maxNC"));
    optionsList.add(options.getOption("dot"));
    optionsList.add(options.getOption("sdot"));
    optionsList.add(options.getOption("sampleProfile"));
    optionsList.add(options.getOption("v"));
    optionsList.add(options.getOption("h"));

    CommandLineParser parser = new BasicParser();
    CommandLine cmdLine = null;
    HelpFormatter hf = new HelpFormatter();
    hf.setOptionComparator(new OptionComarator<Option>(optionsList));
    try {
        cmdLine = parser.parse(options, args);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        hf.printHelp(PROG_NAME, options);
        System.exit(-1);
    }
    Args params = new Args();
    if (cmdLine.hasOption("dir")) {
        params.simPath = cmdLine.getOptionValue("dir") + "/" + SIMULATION_DATA_DIR;
    } else {
        System.err.println("Required parameter: output directory path [-dir]");
        hf.printHelp(PROG_NAME, options);
        System.exit(-1);
    }
    if (cmdLine.hasOption("t")) {
        Parameters.NUM_TREES = Integer.parseInt(cmdLine.getOptionValue("t"));
    }
    if (cmdLine.hasOption("i")) {
        Parameters.NUM_ITERATIONS = Integer.parseInt(cmdLine.getOptionValue("i"));
    }
    if (cmdLine.hasOption("snv")) {
        Parameters.PROB_SNV = Double.parseDouble(cmdLine.getOptionValue("snv"));
    }
    if (cmdLine.hasOption("cnv")) {
        Parameters.PROB_CNV = Double.parseDouble(cmdLine.getOptionValue("cnv"));
    }
    if (cmdLine.hasOption("probDeath")) {
        Parameters.PROB_DEATH = Double.parseDouble(cmdLine.getOptionValue("probDeath"));
    }
    if (cmdLine.hasOption("maxPopulationSize")) {
        Parameters.MAX_POPULATION_SIZE = Integer.parseInt(cmdLine.getOptionValue("maxPopulationSize"));
    }
    if (cmdLine.hasOption("minNodes")) {
        Parameters.MIN_NUM_NODES = Integer.parseInt(cmdLine.getOptionValue("minNodes"));
        if (Parameters.MIN_NUM_NODES < 1) {
            System.err.println("Minimum number of nodes [-minNodes] must be at least 1");
            System.exit(-1);
        }
    }
    if (cmdLine.hasOption("maxNodes")) {
        Parameters.MAX_NUM_NODES = Integer.parseInt(cmdLine.getOptionValue("maxNodes"));
        if (Parameters.MAX_NUM_NODES < 1 || Parameters.MAX_NUM_NODES < Parameters.MIN_NUM_NODES) {
            System.err.println(
                    "Maximum number of nodes [-maxNodes] must be at least 1 and not less than [-minNodes]");
            System.exit(-1);
        }
    }
    if (cmdLine.hasOption("s")) {
        String[] samples = cmdLine.getOptionValues("s");
        Parameters.NUM_SAMPLES_ARRAY = new int[samples.length];
        for (int i = 0; i < samples.length; i++) {
            Parameters.NUM_SAMPLES_ARRAY[i] = Integer.parseInt(samples[i]);
        }
    }
    if (cmdLine.hasOption("c")) {
        String[] cov = cmdLine.getOptionValues("c");
        Parameters.COVERAGE_ARRAY = new int[cov.length];
        for (int i = 0; i < cov.length; i++) {
            Parameters.COVERAGE_ARRAY[i] = Integer.parseInt(cov[i]);
        }
    }
    if (cmdLine.hasOption("maxSubclones")) {
        Parameters.MAX_NUM_SUBCLONES = Integer.parseInt(cmdLine.getOptionValue("maxSubclones"));
    }
    if (cmdLine.hasOption("sampleSize")) {
        Parameters.NUM_CELLS_PER_SAMPLE = Integer.parseInt(cmdLine.getOptionValue("sampleSize"));
    }
    if (cmdLine.hasOption("e")) {
        Parameters.SEQUENCING_ERROR = Double.parseDouble(cmdLine.getOptionValue("e"));
    }
    if (cmdLine.hasOption("minNC")) {
        Parameters.MIN_PERCENT_NORMAL_CONTAMINATION = Double.parseDouble(cmdLine.getOptionValue("minNC"));
    }
    if (cmdLine.hasOption("maxNC")) {
        Parameters.MAX_PERCENT_NORMAL_CONTAMINATION = Double.parseDouble(cmdLine.getOptionValue("maxNC"));
    }
    if (Parameters.MAX_PERCENT_NORMAL_CONTAMINATION < Parameters.MIN_PERCENT_NORMAL_CONTAMINATION) {
        Parameters.MAX_PERCENT_NORMAL_CONTAMINATION = Parameters.MIN_PERCENT_NORMAL_CONTAMINATION;
    }

    /*if(cmdLine.hasOption("localized")) {
       Parameters.LOCALIZED_SAMPLING = true;
    }
    if(cmdLine.hasOption("mixSubclone")) {
       Parameters.MIX_NBR_SUBTREE_SUBCLONE = true;
    }*/

    if (cmdLine.hasOption("dot")) {
        params.generateDOT = true;
    }
    if (cmdLine.hasOption("sampledDot")) {
        params.generateSampledDOT = true;
    }
    if (cmdLine.hasOption("sampleProfile")) {
        params.outputSampleProfile = true;
    }
    if (cmdLine.hasOption("h")) {
        new HelpFormatter().printHelp(" ", options);
    }
    // logger
    ConsoleHandler h = new ConsoleHandler();
    h.setFormatter(new LogFormatter());
    h.setLevel(Level.INFO);
    logger.setLevel(Level.INFO);
    if (cmdLine.hasOption("v")) {
        h.setLevel(Level.FINEST);
        logger.setLevel(Level.FINEST);
    }
    logger.addHandler(h);
    logger.setUseParentHandlers(false);

    // validate settings
    if (Parameters.PROB_SNV + Parameters.PROB_CNV + Parameters.PROB_DEATH > 1) {
        System.err.println("The sum of SSNV, CNV, and cell death probabilities cannot exceed 1");
        hf.printHelp(PROG_NAME, options);
        System.exit(-1);
    }
    simulateLineageTrees(params);
}

From source file:core.PlanC.java

/**
 * inicio de aplicacion//from   www  .  ja  v  a2  s. c  o m
 * 
 * @param arg - argumentos de entrada
 */
public static void main(String[] args) {

    // user.name

    /*
     * Properties prp = System.getProperties(); System.out.println(getWmicValue("bios", "SerialNumber"));
     * System.out.println(getWmicValue("cpu", "SystemName"));
     */

    try {
        // log
        // -Djava.util.logging.SimpleFormatter.format='%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s %2$s %5$s%6$s%n'
        // System.setProperty("java.util.logging.SimpleFormatter.format",
        // "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s %2$s %5$s%6$s%n");
        System.setProperty("java.util.logging.SimpleFormatter.format",
                "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %5$s%6$s%n");

        FileHandler fh = new FileHandler(LOG_FILE);
        fh.setFormatter(new SimpleFormatter());
        fh.setLevel(Level.INFO);
        ConsoleHandler ch = new ConsoleHandler();
        ch.setFormatter(new SimpleFormatter());
        ch.setLevel(Level.INFO);
        logger = Logger.getLogger("");
        Handler[] hs = logger.getHandlers();
        for (int x = 0; x < hs.length; x++) {
            logger.removeHandler(hs[x]);
        }
        logger.addHandler(fh);
        logger.addHandler(ch);
        // point apache log to this log
        System.setProperty("org.apache.commons.logging.Log", Jdk14Logger.class.getName());

        TPreferences.init();
        TStringUtils.init();

        Font fo = Font.createFont(Font.TRUETYPE_FONT, TResourceUtils.getFile("Dosis-Light.ttf"));
        GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(fo);
        fo = Font.createFont(Font.TRUETYPE_FONT, TResourceUtils.getFile("Dosis-Medium.ttf"));
        GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(fo);
        fo = Font.createFont(Font.TRUETYPE_FONT, TResourceUtils.getFile("AERO_ITALIC.ttf"));
        GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(fo);

        SwingTimerTimingSource ts = new SwingTimerTimingSource();
        AnimatorBuilder.setDefaultTimingSource(ts);
        ts.init();

        // parse app argument parameters and append to tpreferences to futher uses
        for (String arg : args) {
            String[] kv = arg.split("=");
            TPreferences.setProperty(kv[0], kv[1]);
        }
        RUNNING_MODE = TPreferences.getProperty("runningMode", RM_NORMAL);

        newMsg = Applet.newAudioClip(TResourceUtils.getURL("newMsg.wav"));

    } catch (Exception e) {
        SystemLog.logException1(e, true);
    }

    // pass icon from metal to web look and feel
    Icon i1 = UIManager.getIcon("OptionPane.errorIcon");
    Icon i2 = UIManager.getIcon("OptionPane.informationIcon");
    Icon i3 = UIManager.getIcon("OptionPane.questionIcon");
    Icon i4 = UIManager.getIcon("OptionPane.warningIcon");
    // Object fcui = UIManager.get("FileChooserUI");
    // JFileChooser fc = new JFileChooser();

    WebLookAndFeel.install();
    // WebLookAndFeel.setDecorateFrames(true);
    // WebLookAndFeel.setDecorateDialogs(true);

    UIManager.put("OptionPane.errorIcon", i1);
    UIManager.put("OptionPane.informationIcon", i2);
    UIManager.put("OptionPane.questionIcon", i3);
    UIManager.put("OptionPane.warningIcon", i4);
    // UIManager.put("TFileChooserUI", fcui);

    // warm up the IDW.
    // in my computer, some weird error ocurr if i don't execute this preload.
    new RootWindow(null);

    frame = new TWebFrame();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            Exit.shutdown();
        }
    });

    if (RUNNING_MODE.equals(RM_NORMAL)) {
        initEnviorement();
    }
    if (RUNNING_MODE.equals(RM_CONSOLE)) {
        initConsoleEnviorement();
    }

    if (RUNNING_MODE.equals(ONE_TASK)) {
        String cln = TPreferences.getProperty("taskName", "*TaskNotFound");
        PlanC.logger.log(Level.INFO, "OneTask parameter found in .properties. file Task name = " + cln);
        try {
            Class cls = Class.forName(cln);
            Object dobj = cls.newInstance();
            // new class must be extends form AbstractExternalTask
            TTaskManager.executeTask((Runnable) dobj);
            return;
        } catch (Exception e) {
            PlanC.logger.log(Level.SEVERE, e.getMessage(), e);
            Exit.shutdown();
        }
    }
}

From source file:org.geotools.styling.css.CssTranslator.java

public static void main(String[] args) throws IOException, TransformerException {
    if (args.length != 2) {
        System.err.println("Usage: CssTranslator <input.css> <output.sld>");
        System.exit(-1);// www . j av  a  2s.c  o m
    }
    File input = new File(args[0]);
    if (!input.exists()) {
        System.err.println("Could not locate input file " + input.getPath());
        System.exit(-2);
    }
    File output = new File(args[1]);
    File outputParent = output.getParentFile();
    if (!outputParent.exists() && !outputParent.mkdirs()) {
        System.err.println("Output file parent directory does not exist, and cannot be created: "
                + outputParent.getPath());
        System.exit(-2);
    }

    long start = System.currentTimeMillis();

    String css = FileUtils.readFileToString(input);
    Stylesheet styleSheet = CssParser.parse(css);

    java.util.logging.ConsoleHandler handler = new java.util.logging.ConsoleHandler();
    handler.setLevel(java.util.logging.Level.FINE);

    org.geotools.util.logging.Logging.getLogger("org.geotools.styling.css")
            .setLevel(java.util.logging.Level.FINE);
    org.geotools.util.logging.Logging.getLogger("org.geotools.styling.css").addHandler(handler);

    CssTranslator translator = new CssTranslator();
    Style style = translator.translate(styleSheet);

    StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer layer = styleFactory.createNamedLayer();
    layer.addStyle((org.geotools.styling.Style) style);
    sld.layers().add(layer);
    SLDTransformer tx = new SLDTransformer();
    tx.setIndentation(2);
    try (FileOutputStream fos = new FileOutputStream(output)) {
        tx.transform(sld, fos);
    }
    long end = System.currentTimeMillis();

    System.out.println("Translation performed in " + (end - start) / 1000d + " seconds");
}

From source file:com.mobius.software.mqtt.performance.controller.ControllerRunner.java

private static void configureConsoleLogger() {
    Logger l = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
    l.setLevel(Level.INFO);//from ww  w.j  a v a 2  s.  co m
    l.setUseParentHandlers(false);
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.INFO);
    l.addHandler(ch);
}

From source file:Main.java

/**
 * Tells Java's Logging infrastructure to output whatever it possibly can, this is only needed
 * in Java, not in Android.//from  ww w . ja  va2 s.com
 */
public static void outputAsMuchLoggingAsPossible() {
    Logger log = Logger.getLogger("com.couchbase.lite");
    ConsoleHandler handler = new ConsoleHandler();
    handler.setLevel(Level.ALL);
    log.addHandler(handler);
    log.setLevel(Level.ALL);
}

From source file:com.google.oacurl.util.LoggingConfig.java

public static void enableWireLog() {
    // For clarity, override the formatter so that it doesn't print the
    // date and method name for each line, and then munge the output a little
    // bit to make it nicer and more curl-like.
    Formatter wireFormatter = new Formatter() {
        @Override//  ww  w  . j  av  a2 s .c o  m
        public String format(LogRecord record) {
            String message = record.getMessage();
            String trimmedMessage = message.substring(">> \"".length(), message.length() - 1);
            if (trimmedMessage.matches("[0-9a-f]+\\[EOL\\]")) {
                return "";
            }

            trimmedMessage = trimmedMessage.replace("[EOL]", "");
            if (trimmedMessage.isEmpty()) {
                return "";
            }

            StringBuilder out = new StringBuilder();
            out.append(message.charAt(0));
            out.append(" ");
            out.append(trimmedMessage);
            out.append(System.getProperty("line.separator"));
            return out.toString();
        }
    };

    ConsoleHandler wireHandler = new ConsoleHandler();
    wireHandler.setLevel(Level.FINE);
    wireHandler.setFormatter(wireFormatter);

    Logger wireLogger = Logger.getLogger("org.apache.http.wire");
    wireLogger.setLevel(Level.FINE);
    wireLogger.setUseParentHandlers(false);
    wireLogger.addHandler(wireHandler);
}

From source file:com.frostvoid.trekwar.server.TrekwarServer.java

/**
 * Initiates logging/*from ww  w  .j  av a  2s. c o m*/
 *
 * @throws IOException
 */
private static void initLogging() throws IOException {
    FileHandler fh = new FileHandler(galaxyFileName + ".log");
    fh.setLevel(LOG.getLevel());
    Formatter logFormat = new Formatter() {

        @Override
        public String format(LogRecord rec) {
            StringBuilder buf = new StringBuilder(200);
            buf.append("#");
            buf.append(new java.util.Date());
            buf.append(' ');
            buf.append(rec.getLevel());
            buf.append(' ');
            buf.append(rec.getSourceClassName()).append(".").append(rec.getSourceMethodName());
            buf.append(":\n");
            buf.append(formatMessage(rec));
            buf.append('\n');
            return buf.toString();
        }
    };
    fh.setFormatter(logFormat);

    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(LOG.getLevel());
    Formatter conlogFormat = new Formatter() {
        @Override
        public String format(LogRecord rec) {
            StringBuilder buf = new StringBuilder(200);
            buf.append(rec.getLevel());
            buf.append(": ");
            buf.append(formatMessage(rec));
            buf.append('\n');
            return buf.toString();
        }
    };
    ch.setFormatter(conlogFormat);

    LOG.addHandler(fh);
    LOG.addHandler(ch);
}

From source file:dk.hippogrif.prettyxml.PrettyPrint.java

static String loadConfiguration(String resource) {
    try {/*from  w w w.  j  a  v a 2s .c om*/
        Properties prop = loadPropertiesResource(resource);

        // logging
        String loggingLevel = prop.getProperty("logging.Level");
        if (loggingLevel != null) {
            Level level = Level.parse(loggingLevel);
            Logger l = Logger.getLogger("dk.hippogrif.prettyxml");
            l.setLevel(level);
            if ("ConsoleHandler".equals(prop.getProperty("logging.Handler"))) {
                ConsoleHandler h = new ConsoleHandler();
                h.setLevel(level);
                l.addHandler(h);
            } else if ("FileHandler".equals(prop.getProperty("logging.Handler"))) {
                FileHandler h = new FileHandler(System.getProperty("user.home") + "/prettyxml.log");
                h.setLevel(level);
                l.addHandler(h);
            }
            logger.config("logging.Level=" + loggingLevel);
        }

        // version
        version = prop.getProperty("version", "");
        logger.config("version=" + version);

        // wellknown encodings
        String s = prop.getProperty("encodings");
        if (s == null) {
            throw new Exception("encodings missing in prettyxml.properties");
        }
        encodings = s.split(";");

        // wellknown property settings
        s = prop.getProperty("settings");
        if (s == null) {
            throw new Exception("settings missing in prettyxml.properties");
        }
        settings = s.split(";");
        setting = new HashMap();
        for (int i = 0; i < settings.length; i++) {
            String name = settings[i];
            Properties props = loadPropertiesResource(name + ".properties");
            checkProperties(props, false);
            setting.put(name, props);
        }

        // wellknown transformations
        s = prop.getProperty("transformations");
        if (s == null) {
            throw new Exception("transformations missing in prettyxml.properties");
        }
        transformations = s.split(";");
        transformation = new HashMap();
        for (int i = 0; i < transformations.length; i++) {
            String name = transformations[i];
            transformation.put(name, mkTransformerResource(name + ".xslt"));
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return version;
}