package net.kencochrane.raven.logback;

import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.util.StatusPrinter;
import mockit.Mock;
import mockit.MockUp;

public class MockUpStatusPrinter extends MockUp<StatusPrinter> {
    @Mock
    public static void buildStr(StringBuilder sb, String indentation, Status s) {
        sb.append("[RAVEN] ErrorHandler ")
                .append("[").append(getLevel(s)).append("] ")
                .append(s.getOrigin()).append(" - ")
                .append(s.getMessage())
                .append(CoreConstants.LINE_SEPARATOR);
    }

    private static String getLevel(Status s) {
        switch (s.getEffectiveLevel()) {
            case Status.INFO:
                return "INFO";
            case Status.WARN:
                return "WARN";
            case Status.ERROR:
                return "ERROR";
            default:
                return "UNKOWN";
        }
    }
}

package net.kencochrane.raven.logback;

import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.util.StatusPrinter;
import mockit.Mock;
import mockit.MockUp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MockUpStatusPrinter extends MockUp<StatusPrinter> {
    private static final Logger logger = LoggerFactory.getLogger("ErrorHandler");

    @Mock
    public static void buildStr(StringBuilder sb, String indentation, Status s) {
        switch (s.getEffectiveLevel()) {
            case Status.INFO:
                logger.info("{} - {}", s.getOrigin(), s.getMessage());
                return;
            case Status.WARN:
                logger.warn("{} - {}", s.getOrigin(), s.getMessage());
                return;
            case Status.ERROR:
                logger.error("{} - {}", s.getOrigin(), s.getMessage());
                return;
            default:
                logger.debug("{} - {}", s.getOrigin(), s.getMessage());
                return;
        }
    }
}

Send errorHandler messages through a logger (to change the log level if necessary)
Send errorHandler messages through a logger (to change the log level if necessary)
