1 17 package org.apache.ws.jaxme.logging; 18 19 import java.io.PrintWriter ; 20 import java.io.StringWriter ; 21 22 import org.apache.tools.ant.Project; 23 import org.apache.tools.ant.Task; 24 25 27 public class AntProjectLogger implements Logger { 28 private final String cName; 29 private final Task task; 30 31 33 public AntProjectLogger(String pName, Task pTask) { 34 cName = pName; 35 task = pTask; 36 } 37 38 public boolean isFinestEnabled() { return true; } 39 public boolean isFinerEnabled() { return true; } 40 public boolean isFineEnabled() { return true; } 41 public boolean isInfoEnabled() { return true; } 42 public boolean isWarnEnabled() { return true; } 43 public boolean isErrorEnabled() { return true; } 44 45 protected String asString(Object [] pDetails) { 46 if (pDetails == null) { 47 return ""; 48 } 49 StringBuffer sb = new StringBuffer (); 50 for (int i = 0; i < pDetails.length; i++) { 51 if (i > 0) { 52 sb.append(", "); 53 } 54 sb.append(pDetails[i]); 55 } 56 return sb.toString(); 57 } 58 59 protected void log(int pLevel, String mName, String pMsg) { 60 task.log(cName + "." + mName + ": " + pMsg, pLevel); 61 } 62 63 public void entering(String mName, Object [] pDetails) { 64 log(Project.MSG_VERBOSE, mName, "-> " + asString(pDetails)); 65 } 66 67 public void entering(String mName) { 68 log(Project.MSG_VERBOSE, mName, "->"); 69 } 70 71 public void entering(String mName, Object pDetails) { 72 log(Project.MSG_VERBOSE, mName, "-> " + pDetails); 73 } 74 75 public void exiting(String mName, Object [] pDetails) { 76 log(Project.MSG_VERBOSE, mName, "<- " + asString(pDetails)); 77 } 78 79 public void exiting(String mName) { 80 log(Project.MSG_VERBOSE, mName, "<-"); 81 } 82 83 public void exiting(String mName, Object pDetails) { 84 log(Project.MSG_VERBOSE, mName, "<- " + pDetails); 85 } 86 87 public void throwing(String mName, Throwable pThrowable) { 88 StringWriter sw = new StringWriter (); 89 pThrowable.printStackTrace(new PrintWriter (sw)); 90 error(mName, sw.toString()); 91 } 92 93 public void finest(String mName, String pMsg, Object [] pDetails) { 94 finest(mName, pMsg + ", " + asString(pDetails)); 95 } 96 97 public void finest(String mName, String pMsg) { 98 log(Project.MSG_DEBUG, mName, pMsg); 99 } 100 101 public void finest(String mName, String pMsg, Object pDetails) { 102 finest(mName, pMsg + ", " + pDetails); 103 } 104 105 public void finer(String mName, String pMsg, Object [] pDetails) { 106 finer(mName, pMsg + ", " + asString(pDetails)); 107 } 108 109 public void finer(String mName, String pMsg) { 110 log(Project.MSG_DEBUG, mName, pMsg); 111 } 112 113 public void finer(String mName, String pMsg, Object pDetails) { 114 finer(mName, pMsg + ", " + pDetails); 115 } 116 117 public void fine(String mName, String pMsg, Object [] pDetails) { 118 fine(mName, pMsg + ", " + asString(pDetails)); 119 } 120 121 public void fine(String mName, String pMsg) { 122 log(Project.MSG_VERBOSE, mName, pMsg); 123 } 124 125 public void fine(String mName, String pMsg, Object pDetails) { 126 fine(mName, pMsg + ", " + pDetails); 127 } 128 129 public void info(String mName, String pMsg, Object [] pDetails) { 130 info(mName, pMsg + ", " + asString(pDetails)); 131 } 132 133 public void info(String mName, String pMsg) { 134 log(Project.MSG_INFO, mName, pMsg); 135 } 136 137 public void info(String mName, String pMsg, Object pDetails) { 138 info(mName, pMsg + ", " + pDetails); 139 } 140 141 public void warn(String mName, String pMsg, Object [] pDetails) { 142 warn(mName, pMsg + ", " + asString(pDetails)); 143 } 144 145 public void warn(String mName, String pMsg) { 146 log(Project.MSG_WARN, mName, pMsg); 147 } 148 149 public void warn(String mName, String pMsg, Object pDetails) { 150 warn(mName, pMsg + ", " + pDetails); 151 } 152 153 public void error(String mName, String pMsg, Object [] pDetails) { 154 error(mName, pMsg + ", " + asString(pDetails)); 155 } 156 157 public void error(String mName, String pMsg) { 158 log(Project.MSG_ERR, mName, pMsg); 159 } 160 161 public void error(String mName, String pMsg, Object pDetails) { 162 error(mName, pMsg + ", " + pDetails); 163 } 164 } 165 | Popular Tags |