1 19 package org.netbeans.mdrant; 20 21 import java.io.*; 22 import java.util.*; 23 import org.openide.ErrorManager; 24 import org.apache.tools.ant.Project; 25 import org.apache.tools.ant.Task; 26 27 32 public class MdrantLogger extends ErrorManager 33 { 34 private static Task task; 35 36 public MdrantLogger() 37 { 38 } 39 40 static void setTask(Task newTask) 41 { 42 task = newTask; 43 } 44 45 public Throwable attachAnnotations( 47 Throwable t, Annotation[] arr) 48 { 49 return t; 50 } 51 52 public Annotation[] findAnnotations(Throwable t) 54 { 55 return null; 56 } 57 58 public Throwable annotate( 60 Throwable t, int severity, 61 String message, String localizedMessage, 62 Throwable stackTrace, java.util.Date date) 63 { 64 if (task != null) { 65 task.log(message, convertSeverity(severity)); 66 } 67 return t; 68 } 69 70 public void notify(int severity, Throwable t) 72 { 73 if (task != null) { 74 task.log(t.toString(), convertSeverity(severity)); 75 } 76 } 77 78 public void log(int severity, String s) 80 { 81 if (task != null) { 82 task.log(s, convertSeverity(severity)); 83 } 84 } 85 86 public ErrorManager getInstance(String name) 88 { 89 return this; 90 } 91 92 private static int convertSeverity(int severity) 93 { 94 switch(severity) { 95 case INFORMATIONAL: 96 return Project.MSG_VERBOSE; 97 case WARNING: 98 return Project.MSG_WARN; 99 case USER: 100 return Project.MSG_INFO; 101 case EXCEPTION: 102 return Project.MSG_ERR; 103 case ERROR: 104 return Project.MSG_ERR; 105 default: 106 return Project.MSG_DEBUG; 107 } 108 } 109 } 110 111 | Popular Tags |