1 23 24 package com.sun.enterprise.tools.guiframework.event.handlers; 25 26 import com.iplanet.jato.RequestContext; 27 import com.sun.enterprise.tools.guiframework.view.HandlerContext; 28 import com.sun.enterprise.tools.guiframework.util.LogUtil; 29 import java.util.Map ; 30 import java.util.List ; 31 import java.util.logging.Level ; 32 33 36 public class DebugHandlers { 37 38 44 public void println(RequestContext reqCtx, HandlerContext handlerCtx) { 45 Level level = LogUtil.stringToLogLevel((String ) handlerCtx.getInputValue(LEVEL)); 46 47 String label = (String )handlerCtx.getInputValue(LABEL); 48 if (label == null) { 49 label = ""; 50 } 51 52 Object value = handlerCtx.getInputValue(VALUE); 53 if (value == null) { 54 LogUtil.log(level, label+"null"); 55 } 56 else if (value instanceof List ) { 57 List l = (List )value; 58 for (int i=0; i<l.size(); i++) { 59 Object o = l.get(i); 60 if (o == null) { 61 LogUtil.log(level, label+"null"); 62 } else { 63 LogUtil.log(level, label+o.toString()); 64 } 65 } 66 } else if (value instanceof Exception ) { 67 LogUtil.log(level, label+((Exception )value).getMessage()); 68 } else if (value != null) { 69 LogUtil.log(level, label+value.toString()); 70 } 71 } 72 73 76 public void logException(RequestContext ctx, HandlerContext handlerCtx) { 77 Throwable ex = (Throwable )handlerCtx.getInputValue(EXCEPTION_TO_LOG); 78 String logLevel = (String )handlerCtx.getInputValue(LEVEL); 79 if (logLevel == null) 80 logLevel = "FINE"; 81 Level level = LogUtil.stringToLogLevel(logLevel); 82 83 if (ex != null) { 84 LogUtil.log(level, "", ex); 85 } else { 86 LogUtil.log(level, getClass().getName()+ 87 ".logException() called without an exception to log."); 88 } 89 } 90 91 public static final String VALUE = "value"; 92 public static final String LABEL = "label"; 93 public static final String LEVEL = "level"; 94 public static final String EXCEPTION_TO_LOG = "exceptionToLog"; 95 } 96 | Popular Tags |