| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  |  | 
            
  
    | 16 |  | package org.kuali.student.common.util; | 
            
  
    | 17 |  |  | 
            
  
    | 18 |  | import org.aspectj.lang.JoinPoint; | 
            
  
    | 19 |  | import org.slf4j.Logger; | 
            
  
    | 20 |  | import org.slf4j.LoggerFactory; | 
            
  
    | 21 |  | import org.springframework.aop.ThrowsAdvice; | 
            
  
    | 22 |  |  | 
            
  
    | 23 |  |  | 
            
  
    | 24 |  |  | 
            
  
    | 25 |  |  | 
            
  
    | 26 |  |  | 
            
  
    | 27 |  |  | 
            
  
    | 28 |  |  | 
            
  
    | 29 |  |  | 
            
  
    | 30 |  |  | 
            
  
    | 31 |  |  | 
            
  
    | 32 |  |  | 
            
  
    | 33 |  |  | 
            
  
    | 34 |  |  | 
            
  
    | 35 |  |  | 
            
  
    | 36 |  |  | 
            
  
    | 37 |  |  | 
            
  
    | 38 |  |  | 
            
  
    | 39 |  |  | 
            
  
    | 40 |  |  | 
            
  
    | 41 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 43 (43) | Complexity: 17 | Complexity Density: 0.53 |  | 
  
  
    | 42 |  | public class SimpleExceptionLoggingAdvice implements ThrowsAdvice { | 
            
  
    | 43 |  |  | 
               
        |  |  | 
           
           |  | - | Uncovered Elements: 0 (0) | Complexity: 0 | Complexity Density: - |  | 
  
  
    | 44 |  | private enum ExceptionLevel{THROWABLE, EXCEPTION, RUNTIME}; | 
            
  
    | 45 |  | private ExceptionLevel exceptionType = ExceptionLevel.THROWABLE; | 
            
  
    | 46 |  |  | 
               
        |  |  | 
           
           |  | - | Uncovered Elements: 0 (0) | Complexity: 0 | Complexity Density: - |  | 
  
  
    | 47 |  | private enum LoggingLevel{NONE, DEBUG, INFO, WARN, ERROR, STACKTRACE}; | 
            
  
    | 48 |  | private LoggingLevel loggingLevel = LoggingLevel.STACKTRACE; | 
            
  
    | 49 |  |  | 
            
  
    | 50 |  |  | 
            
  
    | 51 |  |  | 
            
  
    | 52 |  |  | 
               
        |  |  | 
           
           |  | - | Uncovered Elements: 0 (0) | Complexity: 1 | Complexity Density: - |  | 
  
  
    | 53 | 0 |  public SimpleExceptionLoggingAdvice() {... | 
            
  
    | 54 |  | } | 
            
  
    | 55 |  |  | 
            
  
    | 56 |  |  | 
            
  
    | 57 |  |  | 
            
  
    | 58 |  |  | 
            
  
    | 59 |  |  | 
            
  
    | 60 |  |  | 
            
  
    | 61 |  |  | 
            
  
    | 62 |  |  | 
            
  
    | 63 |  |  | 
            
  
    | 64 |  |  | 
            
  
    | 65 |  |  | 
            
  
    | 66 |  |  | 
            
  
    | 67 |  | @param | 
            
  
    | 68 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 69 | 0 |  public void setLoggingLevel(String loggingLevel) {... | 
            
  
    | 70 | 0 | this.loggingLevel = LoggingLevel.valueOf(loggingLevel.toUpperCase()); | 
            
  
    | 71 |  | } | 
            
  
    | 72 |  |  | 
            
  
    | 73 |  |  | 
            
  
    | 74 |  |  | 
            
  
    | 75 |  |  | 
            
  
    | 76 |  |  | 
            
  
    | 77 |  |  | 
            
  
    | 78 |  |  | 
            
  
    | 79 |  |  | 
            
  
    | 80 |  |  | 
            
  
    | 81 |  |  | 
            
  
    | 82 |  |  | 
            
  
    | 83 |  |  | 
            
  
    | 84 |  | @param | 
            
  
    | 85 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 86 | 0 |  public void setExceptionLoggingType(String exceptionType) {... | 
            
  
    | 87 | 0 | this.exceptionType = ExceptionLevel.valueOf(exceptionType.toUpperCase()); | 
            
  
    | 88 |  | } | 
            
  
    | 89 |  |  | 
            
  
    | 90 |  |  | 
            
  
    | 91 |  |  | 
            
  
    | 92 |  |  | 
            
  
    | 93 |  | @param | 
            
  
    | 94 |  | @param | 
            
  
    | 95 |  | @throws | 
            
  
    | 96 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 17 (17) | Complexity: 7 | Complexity Density: 0.64 |  | 
  
  
    | 97 | 0 |  public void afterThrowing(JoinPoint jp, Throwable t) throws Throwable {... | 
            
  
    | 98 | 0 | switch(this.exceptionType) { | 
            
  
    | 99 | 0 | case THROWABLE: | 
            
  
    | 100 | 0 | if(t instanceof Throwable) { | 
            
  
    | 101 | 0 | logException(jp.getTarget().getClass(), t); | 
            
  
    | 102 |  | } | 
            
  
    | 103 | 0 | case EXCEPTION: | 
            
  
    | 104 | 0 | if(t instanceof Exception) { | 
            
  
    | 105 | 0 | logException(jp.getTarget().getClass(), t); | 
            
  
    | 106 |  | } | 
            
  
    | 107 | 0 | case RUNTIME: | 
            
  
    | 108 | 0 | if(t instanceof RuntimeException) { | 
            
  
    | 109 | 0 | logException(jp.getTarget().getClass(), t); | 
            
  
    | 110 |  | } | 
            
  
    | 111 |  | } | 
            
  
    | 112 | 0 | throw t; | 
            
  
    | 113 |  | } | 
            
  
    | 114 |  |  | 
            
  
    | 115 |  |  | 
            
  
    | 116 |  |  | 
            
  
    | 117 |  |  | 
            
  
    | 118 |  | @param | 
            
  
    | 119 |  | @param | 
            
  
    | 120 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 19 (19) | Complexity: 7 | Complexity Density: 0.37 |  | 
  
  
    | 121 | 0 |  private void logException(Class<?> targetClass, Throwable t) {... | 
            
  
    | 122 | 0 | Logger logger = LoggerFactory.getLogger(targetClass); | 
            
  
    | 123 |  |  | 
            
  
    | 124 | 0 | switch(this.loggingLevel) { | 
            
  
    | 125 | 0 | case NONE: | 
            
  
    | 126 | 0 | break; | 
            
  
    | 127 | 0 | case DEBUG: | 
            
  
    | 128 | 0 | logger.debug(t.getMessage(), t); | 
            
  
    | 129 | 0 | break; | 
            
  
    | 130 | 0 | case INFO: | 
            
  
    | 131 | 0 | logger.info(t.getMessage(), t); | 
            
  
    | 132 | 0 | break; | 
            
  
    | 133 | 0 | case WARN: | 
            
  
    | 134 | 0 | logger.warn(t.getMessage(), t); | 
            
  
    | 135 | 0 | break; | 
            
  
    | 136 | 0 | case ERROR: | 
            
  
    | 137 | 0 | logger.error(t.getMessage(), t); | 
            
  
    | 138 | 0 | break; | 
            
  
    | 139 | 0 | case STACKTRACE: | 
            
  
    | 140 | 0 | logger.error(t.getMessage(), t); | 
            
  
    | 141 | 0 | break; | 
            
  
    | 142 |  | } | 
            
  
    | 143 |  | } | 
            
  
    | 144 |  | } |