1 18 19 package org.objectweb.util.monolog.wrapper.config; 20 21 import org.objectweb.util.monolog.api.Handler; 22 import org.objectweb.util.monolog.api.Level; 23 import org.objectweb.util.monolog.api.LevelFactory; 24 import org.objectweb.util.monolog.api.TopicalLogger; 25 26 import java.io.Serializable ; 27 import java.util.ArrayList ; 28 import java.util.Enumeration ; 29 import java.util.HashMap ; 30 31 39 public class BasicLogger implements TopicalLogger, Serializable { 40 41 47 protected HashMap handlers = null; 48 49 52 protected ArrayList topics = null; 53 54 57 protected LevelFactory levelFactory = null; 58 59 boolean additivity = true; 60 61 64 protected Level level = null; 65 66 BasicLogger(String topic, LevelFactory lf) { 67 topics = new ArrayList (); 68 handlers = new HashMap (); 69 topics.add(topic); 70 levelFactory = lf; 71 } 72 73 76 public void addHandler(Handler h) throws Exception { 77 handlers.put(h.getName(), h); 78 } 79 80 public void removeHandler(Handler h) throws Exception { 81 handlers.remove(h.getName()); 82 } 83 84 public Handler[] getHandler() { 85 return (Handler[]) handlers.values().toArray(new Handler[0]); 86 } 87 88 public Handler getHandler(String hn) { 89 return (Handler) handlers.get(hn); 90 } 91 92 public void removeAllHandlers() throws Exception { 93 handlers.clear(); 94 } 95 96 public void setAdditivity(boolean a) { 97 additivity = a; 98 } 99 100 public boolean getAdditivity() { 101 return additivity; 102 } 103 104 public void addTopic(String topic) throws Exception { 105 if (!topics.contains(topic)) { 106 topics.add(topic); 107 } 108 } 109 110 113 public Enumeration getTopics() { 114 return null; 116 } 117 118 public String [] getTopic() { 119 return (String []) topics.toArray(new String [0]); 120 } 121 122 public void removeTopic(String topic) throws Exception { 123 topics.remove(topic); 124 } 125 126 public String getName() { 129 return (String ) topics.get(0); 130 } 131 132 public void setName(String name) { 133 topics.set(0, name); 134 } 135 136 public String getType() { 137 return "logger"; 138 } 139 140 public String [] getAttributeNames() { 141 return new String [0]; 142 } 143 144 public Object getAttribute(String name) { 145 return null; 146 } 147 148 public Object setAttribute(String name, Object value) { 149 return null; 150 } 151 152 155 public void setIntLevel(int l) { 156 level = levelFactory.getLevel(l); 157 } 158 159 public void setLevel(Level l) { 160 level = l; 161 } 162 163 public int getCurrentIntLevel() { 164 return (level != null ? level.getIntValue() : 0); 165 } 166 167 public Level getCurrentLevel() { 168 return level; 169 } 170 171 public boolean isLoggable(int level) { 172 return false; 173 } 174 175 public boolean isLoggable(Level l) { 176 return false; 177 } 178 179 public boolean isOn() { 180 return false; 181 } 182 183 public void log(int level, Object message) { 184 } 185 186 public void log(Level level, Object message) { 187 } 188 189 public void log(int level, Object message, Throwable throwable) { 190 } 191 192 public void log(Level level, Object message, Throwable throwable) { 193 } 194 195 public void log(int level, Object message, Object location, Object method) { 196 } 197 198 public void log(Level l, Object message, Object location, Object method) { 199 } 200 201 public void log(int level, Object message, Throwable throwable, 202 Object location, Object method) { 203 } 204 205 public void log(Level level, Object message, Throwable throwable, 206 Object location, Object method) { 207 } 208 209 public void turnOn() { 210 } 211 212 public void turnOff() { 213 } 214 } 215 | Popular Tags |