Example usage for org.apache.commons.logging AbstractJULWrapper AbstractJULWrapper

List of usage examples for org.apache.commons.logging AbstractJULWrapper AbstractJULWrapper

Introduction

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

Prototype

protected AbstractJULWrapper() 

Source Link

Usage

From source file:net.community.chest.gitcloud.facade.ServletUtils.java

public static final Log wrapServletContext(final ServletContext context, final Level thresholdLevel) {
    if ((context == null) || (thresholdLevel == null)) {
        throw new IllegalArgumentException("Incomplete wrapper specification");
    }//from  ww w.jav a 2 s. c o m

    return new AbstractJULWrapper() {
        @Override
        public void log(Level level, Object message, Throwable t) {
            if (isEnabled(level)) {
                if (t == null) {
                    context.log(level.getName() + ": " + message);
                } else {
                    context.log(level.getName() + ": " + message, t);
                }
            }
        }

        @Override
        public boolean isEnabled(Level level) {
            if (Level.OFF.equals(thresholdLevel)) {
                return false;
            }

            if (Level.ALL.equals(thresholdLevel)) {
                return true;
            }

            if (level.intValue() >= thresholdLevel.intValue()) {
                return true;
            } else {
                return false; // debug breakpoint
            }
        }
    };
}