Java slf4j Logger profilerTrigger2(Logger log, String msg)

Here you can find the source of profilerTrigger2(Logger log, String msg)

Description

profiler Trigger

License

Apache License

Declaration

public static void profilerTrigger2(Logger log, String msg) 

Method Source Code


//package com.java2s;
/*//from www.ja  v a  2s  .c  o m
 * Copyright 2012-2013 inBloom, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.slf4j.Logger;

public class Main {
    private static boolean includeExceptionMessage;

    public static void profilerTrigger2(Logger log, String msg) {
        log.info("profilerTrigger2(); called");
    }

    /**
     * Write the appropriate info message to the log file
     *
     * @param log
     *            logger to write the message
     * @param message
     *            specific message to write to the log file
     * @param exception
     *            the exception which caused the log file entry
     */
    public static void info(Logger log, String message, Throwable exception) {
        // Log the error with a message-safe exception.
        if (log.isInfoEnabled()) {
            Throwable loggingException = createLoggingException(exception);
            log.info(message, loggingException);
        }
    }

    /**
     * Create a message-safe exception from the original exception
     *
     * @param exception
     *            original exception from which the message-safe exception will be created
     *
     * @return Exception
     *         the new message-safe exception
     */
    private static Throwable createLoggingException(Throwable exception) {
        return createLoggingException(exception, includeExceptionMessage);
    }

    /**
     * Create a message-safe exception from the original exception
     *
     * @param exception
     *            original exception from which the message-safe exception will be created
     *
     * @return Exception
     *         the new message-safe exception
     */
    public static Throwable createLoggingException(Throwable exception, boolean includeMessage) {
        if (includeMessage) {
            return exception;
        }

        Exception loggingException;
        if (exception.getCause() == null) {
            loggingException = new Exception(exception.getClass().toString()); //NOPMD Need to use raw exception as type of exception is unknown
        } else {
            loggingException = new Exception(exception.getClass().toString(), //NOPMD Need to use raw exception as type of exception is unknown
                    createLoggingException(exception.getCause(), includeMessage));
        }
        loggingException.setStackTrace(exception.getStackTrace());
        return loggingException;
    }
}

Related

  1. printInfoLog(Class cla, String message)
  2. printPrettyJson(Logger logger, String json)
  3. printRequestLog(Map reqParam)
  4. printResponseLog(String res)
  5. printStackTrace(Logger logger, Throwable e)
  6. putMDCs(String clientId, String subjectId)
  7. request(String infoMessage)
  8. restoreContext(Map mdcContextMap)
  9. rosettaShell(ArrayList a)