@@ -0,0 +1,2983 @@
+/*%0A * Copyright (c) 2013-2016 Cinchapi Inc.%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A * http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.cinchapi.common.logging;%0A%0Aimport java.util.Map;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.cinchapi.common.reflect.Reflection;%0Aimport com.google.common.collect.Maps;%0A%0A/**%0A * A collection of utility methods for programmatically configuring logging%0A * preferences.%0A * %0A * @author Jeff Nelson%0A */%0Apublic class Logging %7B%0A%0A    /**%0A     * A cache of the object that is passed to the %7B@code setLevel%7D method of%0A     * the appropriate Logger.%0A     */%0A    static Map%3CString, Object%3E levelCache = Maps.newHashMap();%0A%0A    /**%0A     * Disable ALL logging from %7B@code clazz%7D%0A     * %0A     * @param clazz the %7B@link Class%7D for which logging should be disabled%0A     */%0A    public static void disable(Class%3C?%3E clazz) %7B%0A        Logger logger = LoggerFactory.getLogger(clazz);%0A        if(logger instanceof ch.qos.logback.classic.Logger) %7B%0A            ((ch.qos.logback.classic.Logger) logger)%0A                    .setLevel(ch.qos.logback.classic.Level.OFF);%0A        %7D%0A        else if(logger instanceof java.util.logging.Logger) %7B%0A            ((java.util.logging.Logger) logger)%0A                    .setLevel(java.util.logging.Level.OFF);%0A        %7D%0A        else %7B%0A            // This code is very brittle because it calls a lot of stuff using%0A            // reflection. If internal APIs change, this could go bad very%0A            // quickly. The moral of the story is that everyone should just use%0A            // Logback, but since that isn't the reality, we have to live with%0A            // this hack. In actuality, the real moral is that client side code%0A            // should never have logging statements, otherwise we wouldn't have%0A            // to disable them in the first place.%0A            String type = logger.getClass().getName();%0A            Object theLogger = Reflection.get(%22logger%22, logger);%0A            Object level = levelCache.get(type);%0A            if(level == null) %7B%0A                switch (type) %7B%0A                case %22org.slf4j.impl.Log4jLoggerAdapter%22:%0A                default:%0A                    level = Reflection%0A                            .getStatic(%22OFF%22, Reflection%0A                                    .getClassCasted(%22org.apache.log4j.Level%22));%0A                    break;%0A                %7D%0A                levelCache.put(type, level);%0A            %7D%0A            Reflection.call(theLogger, %22setLevel%22, level);%0A        %7D%0A    %7D%0A%7D%0A

add Logging util class