Example usage for org.apache.commons.logging Log isFatalEnabled

List of usage examples for org.apache.commons.logging Log isFatalEnabled

Introduction

In this page you can find the example usage for org.apache.commons.logging Log isFatalEnabled.

Prototype

boolean isFatalEnabled();

Source Link

Document

Is fatal logging currently enabled?

Usage

From source file:org.alfresco.extension.bulkimport.util.LogUtils.java

public final static boolean fatal(final Log log) {
    return (log.isFatalEnabled());
}

From source file:org.apache.ojb.broker.util.logging.CommonsLoggerImpl.java

/**
* @see org.apache.ojb.broker.util.logging.Logger#isEnabledFor(int)
*//*from   www . j a  v a  2 s. c om*/
public boolean isEnabledFor(int priority) {
    Log commonsLog = getLog();
    switch (priority) {
    case Logger.DEBUG:
        return commonsLog.isDebugEnabled();
    case Logger.INFO:
        return commonsLog.isInfoEnabled();
    case Logger.WARN:
        return commonsLog.isWarnEnabled();
    case Logger.ERROR:
        return commonsLog.isErrorEnabled();
    case Logger.FATAL:
        return commonsLog.isFatalEnabled();
    }
    return false;
}

From source file:org.easyrec.utils.spring.log.LoggerUtils.java

/**
 * @param logger//from w w w .  java 2 s . com
 * @param logLevel
 *
 */
public static boolean isLogLevelEnabled(Log logger, String logLevel) {
    if (logLevel.equalsIgnoreCase("info")) {
        if (logger.isInfoEnabled()) {
            return true;
        }
    } else if (logLevel.equalsIgnoreCase("debug")) {
        if (logger.isDebugEnabled()) {
            return true;
        }
    } else if (logLevel.equalsIgnoreCase("error")) {
        if (logger.isErrorEnabled()) {
            return true;
        }
    } else if (logLevel.equalsIgnoreCase("trace")) {
        if (logger.isTraceEnabled()) {
            return true;
        }
    } else if (logLevel.equalsIgnoreCase("warn")) {
        if (logger.isWarnEnabled()) {
            return true;
        }
    } else if (logLevel.equalsIgnoreCase("fatal")) {
        if (logger.isFatalEnabled()) {
            return true;
        }
    } else {
        logger.warn("Passed unknown log level '" + logLevel + "' to Aspect - returning false!");
        return false;
    }
    logger.warn("log level '" + logLevel + "' not enabled - returning false!");
    return false;
}

From source file:org.easyrec.utils.spring.log.LoggerUtils.java

/**
 * Writes the given 'message' to the Log 'logger' with level 'logLevel'.
 *
 * @param logger   the Log to which the message is written
 * @param logLevel the level to which the message is written
 * @param message  the message to be written
 *//*  w  ww. ja  va  2  s  . c  o  m*/
public static void log(Log logger, String logLevel, String message) {
    if (logLevel.equalsIgnoreCase("info")) {
        if (logger.isInfoEnabled()) {
            logger.info(message);
        }
    } else if (logLevel.equalsIgnoreCase("debug")) {
        if (logger.isDebugEnabled()) {
            logger.debug(message);
        }
    } else if (logLevel.equalsIgnoreCase("error")) {
        if (logger.isErrorEnabled()) {
            logger.error(message);
        }
    } else if (logLevel.equalsIgnoreCase("trace")) {
        if (logger.isTraceEnabled()) {
            logger.trace(message);
        }
    } else if (logLevel.equalsIgnoreCase("warn")) {
        if (logger.isWarnEnabled()) {
            logger.warn(message);
        }
    } else if (logLevel.equalsIgnoreCase("fatal")) {
        if (logger.isFatalEnabled()) {
            logger.fatal(message);
        }
    } else {
        logger.error("Passed unknown log level " + logLevel + " to Aspect - logging to error instead!");
        logger.error(message);
    }
}

From source file:org.easyrec.utils.spring.log.LoggerUtils.java

/**
 * Writes the given 'message' to the Log 'logger' with level 'logLevel'.
 *
 * @param logger   the Log to which the message is written
 * @param logLevel the level to which the message is written
 * @param message  the message to be written
 * @param ta       a Throwable passed on to the Log
 *///from w w w. ja  va 2 s . co m
public static void log(Log logger, String logLevel, String message, Throwable ta) {
    if (logLevel.equalsIgnoreCase("info")) {
        if (logger.isInfoEnabled()) {
            logger.info(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("debug")) {
        if (logger.isDebugEnabled()) {
            logger.debug(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("error")) {
        if (logger.isErrorEnabled()) {
            logger.error(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("trace")) {
        if (logger.isTraceEnabled()) {
            logger.trace(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("warn")) {
        if (logger.isWarnEnabled()) {
            logger.warn(message, ta);
        }
    } else if (logLevel.equalsIgnoreCase("fatal")) {
        if (logger.isFatalEnabled()) {
            logger.fatal(message, ta);
        }
    } else {
        logger.error("Passed unknown log level " + logLevel + " to Aspect - logging to error instead!");
        logger.error(message, ta);
    }
}

From source file:org.kuali.kra.logging.BufferedLogger.java

/**
 * Wraps {@link Log#fatal(String)}/*w w  w .  ja  v a 2s  .com*/
 * 
 * @param pattern to format against
 * @param objs an array of objects used as parameters to the <code>pattern</code>
 */
public static final void fatal(Object... objs) {
    Log log = getLogger();
    if (log.isFatalEnabled()) {
        log.fatal(getMessage(objs));
    }
}

From source file:org.latticesoft.util.common.LogUtil.java

public static void main(String args[]) {
    Log log = LogFactory.getLog(LogUtil.class);

    System.out.println(LogUtil.isEnabled("WARNING", "WARNING", true));
    System.out.println(LogUtil.isEnabled("DEBUG", "WARNING", true));
    System.out.println(LogUtil.isEnabled("INFO", "WARNING", true));
    System.out.println(LogUtil.isEnabled("ERROR", "WARNING", true));
    System.out.println(LogUtil.isEnabled("FATAL", "WARNING", true));
    System.out.println("-----");

    System.out.println(LogUtil.isEnabled("WARNING", "DEBUG", true));
    System.out.println(LogUtil.isEnabled("DEBUG", "DEBUG", true));
    System.out.println(LogUtil.isEnabled("INFO", "DEBUG", true));
    System.out.println(LogUtil.isEnabled("ERROR", "DEBUG", true));
    System.out.println(LogUtil.isEnabled("FATAL", "DEBUG", true));
    System.out.println("-----");

    System.out.println(LogUtil.isEnabled("WARNING", "INFO", true));
    System.out.println(LogUtil.isEnabled("DEBUG", "INFO", true));
    System.out.println(LogUtil.isEnabled("INFO", "INFO", true));
    System.out.println(LogUtil.isEnabled("ERROR", "INFO", true));
    System.out.println(LogUtil.isEnabled("FATAL", "INFO", true));
    System.out.println("-----");

    System.out.println(LogUtil.isEnabled("WARNING", "ERROR", true));
    System.out.println(LogUtil.isEnabled("DEBUG", "ERROR", true));
    System.out.println(LogUtil.isEnabled("INFO", "ERROR", true));
    System.out.println(LogUtil.isEnabled("ERROR", "ERROR", true));
    System.out.println(LogUtil.isEnabled("FATAL", "ERROR", true));
    System.out.println("-----");

    System.out.println(LogUtil.isEnabled("WARNING", "FATAL", true));
    System.out.println(LogUtil.isEnabled("DEBUG", "FATAL", true));
    System.out.println(LogUtil.isEnabled("INFO", "FATAL", true));
    System.out.println(LogUtil.isEnabled("ERROR", "FATAL", true));
    System.out.println(LogUtil.isEnabled("FATAL", "FATAL", true));
    System.out.println("-----");

    System.out.println(LogUtil.isEnabled("FATAL", "WARNING", false));

    if (LogUtil.isEnabled("FATAL", "FATAL", log.isFatalEnabled())) {
        LogUtil.log(LogUtil.getLevel("FATAL"), "test", null, log);
    }//from  w  ww .j a  v  a 2  s. c o m

    if (LogUtil.isEnabled("INFO", LogUtil.INFO, log.isInfoEnabled())) {
        LogUtil.log(LogUtil.getLevel("INFO"), "test", null, log);
    }

}

From source file:org.seasar.mayaa.impl.util.xml.XMLHandler.java

public void fatalError(SAXParseException e) {
    Log log = getLog();
    if (log != null && log.isFatalEnabled()) {
        log.fatal(e.getMessage(), e);/*w ww. ja va 2 s . c om*/
    }
    throw new RuntimeException(e);
}

From source file:org.springframework.flex.core.CommonsLoggingTarget.java

public void logEvent(LogEvent logevent) {
    String category = logevent.logger.getCategory();
    if (this.categoryPrefix != null) {
        category = this.categoryPrefix + "." + category;
    }/*w  w  w.j av  a2s.  c o  m*/
    Log log = LogFactory.getLog(category);
    switch (logevent.level) {
    case LogEvent.FATAL:
        if (log.isFatalEnabled()) {
            log.fatal(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.ERROR:
        if (log.isErrorEnabled()) {
            log.error(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.WARN:
        if (log.isWarnEnabled()) {
            log.warn(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.INFO:
        if (log.isInfoEnabled()) {
            log.info(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.DEBUG:
        if (log.isDebugEnabled()) {
            log.debug(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.ALL:
        if (log.isTraceEnabled()) {
            log.trace(logevent.message, logevent.throwable);
        }
        break;
    default:
        break;
    }
}

From source file:org.springframework.kafka.support.LogIfLevelEnabledTests.java

@Test
public void testFatalNoEx() {
    Log theLogger = mock(Log.class);
    LogIfLevelEnabled logger = new LogIfLevelEnabled(theLogger, LogIfLevelEnabled.Level.FATAL);
    given(theLogger.isFatalEnabled()).willReturn(true);
    logger.log(() -> "foo");
    verify(theLogger).isFatalEnabled();/* w w  w.  j ava2s. c  o m*/
    verify(theLogger).fatal(any());
    verifyNoMoreInteractions(theLogger);
}