1 18 19 package sync4j.framework.logging; 20 21 import java.util.logging.Logger ; 22 23 import com.p6spy.engine.logging.appender.FormattedLogger; 24 import com.p6spy.engine.logging.appender.P6Logger; 25 26 33 public class P6SpyLogger extends FormattedLogger implements P6Logger { 34 public static final String LOG_NAME = "sync4j.log.sql"; 35 36 protected Logger log = null; 37 38 public P6SpyLogger() { 39 log = Logger.getLogger(LOG_NAME); 40 } 41 42 public void logSQL(int connectionId, 43 String now , 44 long elapsed , 45 String category , 46 String prepared , 47 String sql ) { 48 49 StringBuffer sb = new StringBuffer (); 50 51 sb.append(now).append(' '); 52 sb.append((connectionId==-1 ? "" : String.valueOf(connectionId))).append(' '); 53 sb.append(category).append(' '); 54 55 if ((prepared != null) && (prepared.length() >= 0)) { 56 logText(sb.toString() + prepared); 57 } 58 59 sb.append(elapsed).append(' '); 60 sb.append(sql).append(' '); 61 62 logText(sb.toString()); 63 } 64 65 public void logText(String text) { 66 log.info(text); 67 setLastEntry(text); 68 } 69 70 public void logException(Exception e) { 71 log.throwing("-", "-", e); 72 } 73 } | Popular Tags |