1 23 24 package com.sun.enterprise.web.logger; 25 26 import java.util.logging.Logger ; 27 import java.util.logging.Level ; 28 import com.sun.enterprise.util.logging.IASLevel; 29 30 38 39 public final class IASLogger extends LoggerBase { 40 41 43 46 Logger _logger = null; 47 48 51 private String _classname; 52 53 56 private String _methodname; 57 58 61 protected static final String info = 62 "com.sun.enterprise.web.logger.IASLogger/1.0"; 63 64 65 67 70 private IASLogger() { 71 super(); 72 } 73 74 80 public IASLogger(Logger logger) { 81 _logger = logger; 82 } 83 84 86 90 protected void write(String msg, int verbosity) { 91 92 if (_logger == null) 93 return; 94 95 Level level = Level.INFO; 96 97 if (verbosity == FATAL) 98 level = (Level )IASLevel.FATAL; 99 else if (verbosity == ERROR) 100 level = Level.SEVERE; 101 else if (verbosity == WARNING) 102 level = Level.WARNING; 103 else if (verbosity == INFORMATION) 104 level = Level.INFO; 105 else if (verbosity == DEBUG) 106 level = Level.FINER; 107 108 inferCaller(); 109 _logger.logp(level, _classname, _methodname, msg); 110 } 111 112 114 118 private void inferCaller() { 119 StackTraceElement stack[] = (new Throwable ()).getStackTrace(); 121 _classname = ""; 122 _methodname = ""; 123 for (int ix=0; ix < stack.length; ix++) { 124 StackTraceElement frame = stack[ix]; 125 _classname = frame.getClassName(); 126 if (!_classname.startsWith("com.sun.enterprise.web.logger")) { 127 _methodname = frame.getMethodName(); 129 return; 130 } 131 } 132 } 133 } 134 | Popular Tags |