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";
        }
    }
}

@@ -37,50 +37,8 @@
 k;%0A%0A
-import ch.qos.logback.core.CoreConstants;%0A
 impo
@@ -163,16 +163,73 @@
 .MockUp;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0Apublic
@@ -287,16 +287,99 @@
 nter%3E %7B%0A
+    private static final Logger logger = LoggerFactory.getLogger(%22ErrorHandler%22);%0A%0A
     @Moc
@@ -475,181 +475,124 @@
    s
-b.append(%22%5BRAVEN%5D ErrorHandler %22)%0A                .append(%22%5B%22).append(getLevel(s)).append(%22%5D %22)%0A                .append(s.getOrigin()).append(%22 - %22)%0A                .append(
+witch (s.getEffectiveLevel()) %7B%0A            case Status.INFO:%0A                logger.info(%22%7B%7D - %7B%7D%22, s.getOrigin(), 
 s.ge
@@ -602,16 +602,17 @@
 ssage())
+;
 %0A       
@@ -624,171 +624,116 @@
     
-.append(CoreConstants.LINE_SEPARATOR)
+return
 ;%0A    
-%7D%0A%0A
     
-private static String getLevel(Status s) %7B%0A        switch (s.getEffectiveLevel()) %7B%0A            case Status.INFO:
+    case Status.WARN:%0A                logger.warn(%22%7B%7D - %7B%7D%22, s.getOrigin(), s.getMessage());
 %0A   
@@ -755,15 +755,8 @@
 turn
- %22INFO%22
 ;%0A  
@@ -769,36 +769,37 @@
     case Status.
-WARN
+ERROR
 :%0A              
@@ -804,53 +804,63 @@
     
-return %22WARN%22;%0A            case Status.ERROR:
+logger.error(%22%7B%7D - %7B%7D%22, s.getOrigin(), s.getMessage());
 %0A   
@@ -882,16 +882,8 @@
 turn
- %22ERROR%22
 ;%0A  
@@ -921,23 +921,86 @@
     
-return %22UNKOWN%22
+logger.debug(%22%7B%7D - %7B%7D%22, s.getOrigin(), s.getMessage());%0A                return
 ;%0A  

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