Java Code Examples for java.util.logging.Level.equals()

The following are Jave code examples for showing how to use equals() of the java.util.logging.Level class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: willtest   File: WebDriverLog.java   View Source Code Vote up 6 votes
private void processWebDriverLogs(WebDriver webDriver) {
    Logs logs = webDriver.manage().logs();
    for (String logType : WEBDRIVER_LOG_LEVELS.keySet()) {
        LOGGER.info("Dumping webdriver log for log type " + logType);
        LogEntries logEntries = logs.get(logType);
        for (LogEntry logEntry : logEntries) {
            String formattedOriginalTimestamp = LOG_TIMESTAMP_FORMAT
                    .format(LocalDateTime.ofInstant(Instant.ofEpochMilli(logEntry.getTimestamp()), ZoneOffset.UTC));
            Level logEntryLevel = logEntry.getLevel();
            if (logEntryLevel.equals(Level.FINE)) {
                LOGGER.debug(MESSAGE_PATTERN, logType, formattedOriginalTimestamp, logEntry.getMessage());
            } else if (logEntryLevel.equals(Level.INFO)) {
                LOGGER.info(MESSAGE_PATTERN, logType, formattedOriginalTimestamp, logEntry.getMessage());
            } else if (logEntryLevel.equals(Level.WARNING)) {
                LOGGER.warn(MESSAGE_PATTERN, logType, formattedOriginalTimestamp, logEntry.getMessage());
            } else if (logEntryLevel.equals(Level.SEVERE)) {
                LOGGER.error(MESSAGE_PATTERN, logType, formattedOriginalTimestamp, logEntry.getMessage());
            } else if (logEntryLevel.equals(Level.FINER)) {
                LOGGER.trace(MESSAGE_PATTERN, logType, formattedOriginalTimestamp, logEntry.getMessage());
            }
        }
    }
}
 
Example 2
Project: rapidminer   File: LogViewer.java   View Source Code Vote up 5 votes
public LogLevelMenu() {
	super("log_level");

	for (final Level level : LogViewer.SELECTABLE_LEVELS) {
		JMenuItem item = new JMenuItem(new AbstractAction(level.getName()) {

			private static final long serialVersionUID = 1L;

			@Override
			public void actionPerformed(ActionEvent e) {
				new Thread(new Runnable() {

					@Override
					public void run() {
						// change the log level outside the EDT
						// no progress thread because the part that may take some time (the
						// GUI refresh by Swing) cannot be cancelled anyway
						setLogLevel(level);
					}
				}).start();
			}
		});

		// highlight current log level
		if (getLogSelectionModel().getCurrentLogModel() != null) {
			if (level.equals(getLogSelectionModel().getCurrentLogModel().getLogLevel())) {
				item.setFont(item.getFont().deriveFont(Font.BOLD));
			}
		}
		add(item);
	}
}
 
Example 3
Project: Nexus   File: Console.java   View Source Code Vote up 5 votes
public boolean log(Level level, String message, Exception exception) {
    if (message != null || exception != null) {
        StringBuilder builder = new StringBuilder();
        if (message != null) {
            builder.append(message);
        }

        if (message != null && exception != null) {
            builder.append("\n");
        }

        if (exception != null) {
            StringWriter writer = new StringWriter();
            exception.printStackTrace(new PrintWriter(writer));

            builder.append(writer.toString());
        }

        logger.log(level, builder.toString());

        Object exit = state.getProperty(ConsoleEvent.EXIT_ON_SEVERE);
        if (exit != null && exit.equals(true) && level.equals(Level.SEVERE)) {
            System.exit(0);
        }
        return true;
    } else {
        return false;
    }
}
 
Example 4
Project: dsp4e   File: LogMessageAccumulator.java   View Source Code Vote up 5 votes
public LogRecord findRecord(Level level, String message) {
	synchronized (records) {
		for (LogRecord r : records) {
			if (level.equals(r.getLevel()) && message.equals(r.getMessage()))
				return r;
		}
		return null;
	}
}