Java Code Examples for org.slf4j.event.Level#toInt()

The following examples show how to use org.slf4j.event.Level#toInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Logger.java    From dkpro-jwpl with Apache License 2.0 6 votes vote down vote up
/**
 * The occurred error with the related log level and message has to be given
 * to this method.
 *
 * This method will verify if the message should be logged or not.
 *
 * @param level
 *            log level
 * @param message
 *            message
 * @param e
 *            Error
 */
public void logError(final Level level, final String message, final Error e)
{
	try {
		Logger errors = LoggingFactory
				.getLogger(LoggingFactory.NAME_ERROR_LOGGER);

		errors.logThrowable(level, message, e);

	}
	catch (LoggingException ex) {
		ex.printStackTrace();
	}

	if (logLevel.toInt() > level.toInt()) {
		return;
	}

	logThrowable(level, message, e);
}
 
Example 2
Source File: Logger.java    From dkpro-jwpl with Apache License 2.0 6 votes vote down vote up
/**
 * The occurred exception with the related log level and message has to be
 * given to this method.
 *
 * This method will verify if the message should be logged or not.
 *
 * @param level
 *            log level
 * @param message
 *            message
 * @param e
 *            Exception
 */
public void logException(final Level level, final String message,
		final Exception e)
{

	try {
		Logger errors = LoggingFactory
				.getLogger(LoggingFactory.NAME_ERROR_LOGGER);

		errors.logThrowable(level, message, e);

	}
	catch (LoggingException ex) {
		ex.printStackTrace();
	}

	if (logLevel.toInt() > level.toInt()) {
		return;
	}

	logThrowable(level, message, e);
}
 
Example 3
Source File: Logger.java    From dkpro-jwpl with Apache License 2.0 6 votes vote down vote up
/**
 * This method will be called with a message and the related log level. It
 * be verified if the message should be logged or not.
 *
 * The format of the logged message is: \t consumerName [ Type of Logger ]
 * \t message \r\n
 *
 * @param level
 *            level
 * @param message
 *            message
 */
public synchronized void logMessage(final Level level, final String message)
{

	if (logLevel.toInt() > level.toInt()) {
		return;
	}

	try {
		this.writer.write(System.currentTimeMillis() + "\t" + consumerName
				+ " [" + type.toString() + "] " + "\t" + message + "\r\n");
		this.writer.flush();
	}
	catch (IOException ioe) {
		ioe.printStackTrace();
	}
}
 
Example 4
Source File: DolphinLoggerUtils.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public static boolean isLevelEnabled(final Level baseLevel, final Level level) {
    Assert.requireNonNull(baseLevel, "baseLevel");
    Assert.requireNonNull(level, "level");
    return baseLevel.toInt() <= level.toInt();
}