Example usage for java.util.logging Logger getGlobal

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

Introduction

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

Prototype

public static final Logger getGlobal() 

Source Link

Document

Return global logger object with the name Logger.GLOBAL_LOGGER_NAME.

Usage

From source file:org.wor.drawca.DrawCAMain.java

/**
 * Main function which start drawing the cellular automata.
 *
 * @param args Command line arguments.//from   w ww  .j  a  v a2  s .  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.azrul.langmera.DecisionService.java

public static void main(String[] args) throws IOException {
    ConfigurationProvider config = null;
    ConfigFilesProvider configFilesProvider = () -> Arrays.asList(Paths.get("config.properties"));
    if (args.length <= 0) {
        ConfigurationSource source = new ClasspathConfigurationSource(configFilesProvider);
        config = new ConfigurationProviderBuilder().withConfigurationSource(source).build();
    } else {/*from   ww  w .  j a va 2  s . c om*/
        ConfigurationSource source = new FilesConfigurationSource(configFilesProvider);
        Environment environment = new ImmutableEnvironment(args[0]);
        config = new ConfigurationProviderBuilder().withConfigurationSource(source).withEnvironment(environment)
                .build();

    }
    Logger logger = null;
    if (config.getProperty("log.file", String.class).isEmpty() == false) {
        FileHandler logHandler = new FileHandler(config.getProperty("log.file", String.class),
                config.getProperty("log.sizePerFile", Integer.class) * 1024 * 1024,
                config.getProperty("log.maxFileCount", Integer.class), true);
        logHandler.setFormatter(new SimpleFormatter());
        logHandler.setLevel(Level.INFO);

        Logger rootLogger = Logger.getLogger("");
        rootLogger.removeHandler(rootLogger.getHandlers()[0]);
        logHandler.setLevel(Level.parse(config.getProperty("log.level", String.class)));
        rootLogger.setLevel(Level.parse(config.getProperty("log.level", String.class)));
        rootLogger.addHandler(logHandler);

        logger = rootLogger;
    } else {
        logger = Logger.getGlobal();
    }

    VertxOptions options = new VertxOptions();
    options.setMaxEventLoopExecuteTime(Long.MAX_VALUE);
    options.setWorkerPoolSize(config.getProperty("workerPoolSize", Integer.class));
    options.setEventLoopPoolSize(40);

    Vertx vertx = Vertx.vertx(options);
    vertx.deployVerticle(new DecisionService(logger, config));
    vertx.deployVerticle(new SaveToDB(logger, config));

}

From source file:ch.gbrain.gwtstorage.test.model.TestItem.java

@Override
public JSONValue toJson() {
    try {/*from ww  w  .  j  a  v a2s. co m*/
        TestItemCodec codec = GWT.create(TestItemCodec.class);
        return codec.encode(this);
    } catch (Exception ex) {
        Logger.getGlobal().log(Level.WARNING, "Failure converting to Json", ex);
    }
    return null;
}

From source file:FileServer.ElasticSearch.ElasticSearchRetrievingInterface.java

public ResultsWrapper<DocumentResultEntity> queryDocument(QueryWrapper queryWrapper) {

    ObjectMapper mapper = new ObjectMapper();

    String url = fileQueryURL;//from ww  w  .  j  ava  2  s  .co m
    String query = QueryStringBuilder.buildDocumentQuery(queryWrapper);

    System.out.println(query);

    ResultsWrapper<DocumentResultEntity> resultList = new ResultsWrapper<>();
    List<DocumentResultEntity> retrievedResults = new ArrayList<>();

    try {

        HttpResponse<String> res = Unirest.post(url).body(query).asString();

        JsonNode root = mapper.readTree(res.getBody());

        System.out.println("*****************************************************************");
        System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
        Logger.getGlobal().log(Level.INFO, mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));

        resultList.setQuery(queryWrapper.extractedContentFeild);
        resultList.setSearchTime(root.get("took").toString());
        resultList.setResultNum(root.get("hits").get("total").toString());

        JsonNode jsonResultList = root.get("hits").get("hits");

        if (jsonResultList.isArray()) {
            for (JsonNode result : jsonResultList) {

                JsonNode content = result.get("_source");

                DocumentResultEntity resultEntity = new DocumentResultEntity();
                resultEntity.fileId = content.get("fileId").asText();
                resultEntity.filename = content.get("filename").asText();
                resultEntity.from = content.get("from").asText();
                resultEntity.to = content.get("to").asText();
                resultEntity.url = fileServerURL + content.get("filename").asText();

                JsonNode highlights = result.get("highlight");

                System.out.println(resultEntity.url);

                if (highlights != null) {
                    StringBuilder builder = new StringBuilder();
                    for (JsonNode snippet : highlights.get("extractedContent")) {
                        builder.append(snippet.asText() + ".....");
                        //fs.extractedContent += snippet.toString() + "...";
                    }

                    resultEntity.extractedContent = builder.toString();
                }

                retrievedResults.add(resultEntity);
            }
        }

        resultList.setResultList(retrievedResults);

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

    return resultList;

}

From source file:yoyo.actor.service.domain.MemberRepositoryImpl.java

/**
 * {@inheritDoc}/*  w w  w  . j  a v  a2  s  .  com*/
 * <dl>
 * <dt>??</dt>
 * <dd>??NULL????</dd>
 * <dt>?</dt>
 * <dd>??????</dd>
 * </dl>
 */
@Override
protected Predicate expression(final MemberFilter filter) {
    Logger.getGlobal().info("filter = " + filter);
    assert filter != null;
    if (StringUtils.isEmpty(filter.getAccount())) {
        return super.expression(filter);
    }
    final CriteriaBuilder b = service.builder();
    final Root<Member> r = service.root();
    return b.equal(r.get(Member_.account), filter.getAccount());
}

From source file:ch.gbrain.gwtstorage.test.model.TestItem.java

@Override
public void fromJson(JSONValue json) {
    try {//from w  ww.  j  ava  2s .c  om
        TestItemCodec codec = GWT.create(TestItemCodec.class);
        TestItem tmp = codec.decode(json);
        if (tmp != null) {
            this.fromJson(tmp);
            this.setTextValue(tmp.textValue);
            this.setBoolValue(tmp.boolValue);
            this.setNumericValue(tmp.numericValue);
        }
    } catch (Exception ex) {
        Logger.getGlobal().log(Level.SEVERE, "Failure converting from Json", ex);
    }
}

From source file:onl.area51.httpd.HttpRequestHandlerBuilder.java

default HttpRequestHandlerBuilder log(Level level) {
    return log(Logger.getGlobal(), level);
}

From source file:onl.area51.httpd.HttpRequestHandlerBuilder.java

default HttpRequestHandlerBuilder log() {
    return log(Logger.getGlobal(), Level.INFO);
}

From source file:io.sqp.proxy.ClientSession.java

public ClientSession(BackendConnectionPool connectionPool, ClientConnection connection) {
    _clientConnection = connection;//from  w w  w  .  j  a  v  a2 s.c o m
    _state = ClientSessionState.Uninitialised;
    _backendConnectionPool = connectionPool;
    logger = Logger.getGlobal();
    _informationProvider = new InformationProvider(logger,
            _backendConnectionPool.getBackend().getTypeRepository());
    _customTypeMapper = new CustomTypeMapper(logger, _backendConnectionPool.getBackend().getTypeRepository());
    _transactionState = TransactionState.AutoCommit;
    _messageQueue = new LinkedList<>();
    _currentLobs = new HashMap<>();
}

From source file:ijfx.service.log.LogService.java

public LogService() {
    super();

    Logger.getGlobal().addHandler(handler);
    //ImageJFX.getLogger().addHandler(handler);

}