All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codacy.scoobydoo.LoggingHelper Maven / Gradle / Ivy

There is a newer version: 3.30.0
Show newest version
package com.codacy.scoobydoo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingHelper {

//    NOTE: If you want to fine tune the log level for some specific classes, i.e. adding this to the logback.xml file:
//    
//        
//    
//    this Logger instance should not be static and at least two constructors should be created: one generic with no
//    args, using the "LoggingHelper.class", and another one accepting the class name (or logger name) as input.
//    As it is now, all loggers are being called "com.codacy.scoobydoo.LoggingHelper".
    private static final Logger LOGGER = LoggerFactory.getLogger(LoggingHelper.class);
    private static final String RP_MESSAGE_FILE_PREFIX = "RP_MESSAGE#FILE#{}#{}";

    public static void info(String message) {
        LOGGER.info(message);
    }

    public static void infoWithScreenshot(String message, String absoluteFilePath) {
        LOGGER.info(RP_MESSAGE_FILE_PREFIX, absoluteFilePath, message);
    }

    public static void error(String message, Throwable error) {
        LOGGER.error(message, error);
    }

    // Use error(String message, Exception exception) instead.
    @Deprecated
    public static void error(String message, String exceptionString) {
        LOGGER.error(message + "/n" + exceptionString);
    }

    public static void errorWithScreenshot(String message, String absoluteFilePath, Throwable error) {
        LOGGER.error(RP_MESSAGE_FILE_PREFIX, absoluteFilePath, message, error);
    }

    // Use errorWithScreenshot(String message, String absoluteFilePath, Exception exception) instead.
    @Deprecated
    public static void errorWithScreenshot(String message, String absoluteFilePath, String exceptionString) {
        LOGGER.error(RP_MESSAGE_FILE_PREFIX, absoluteFilePath, message + "/n" + exceptionString);
    }

    public static void debug(String message) {
        LOGGER.debug(message);
    }

    public static void debugWithScreenshot(String message, String absoluteFilePath) {
        LOGGER.debug(RP_MESSAGE_FILE_PREFIX, absoluteFilePath, message);
    }

    public static void warn(String message) {
        LOGGER.warn(message);
    }

    public static void warnWithScreenshot(String message, String absoluteFilePath) {
        LOGGER.warn(RP_MESSAGE_FILE_PREFIX, absoluteFilePath, message);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy