1 18 package org.objectweb.util.monolog.component; 19 20 import org.objectweb.util.monolog.api.LoggerFactory; 21 import org.objectweb.util.monolog.api.Logger; 22 import org.objectweb.util.monolog.api.LevelFactory; 23 import org.objectweb.util.monolog.api.Level; 24 import org.objectweb.util.monolog.api.HandlerFactory; 25 import org.objectweb.util.monolog.api.Handler; 26 import org.objectweb.util.monolog.api.MonologFactory; 27 import org.objectweb.util.monolog.Monolog; 28 29 import java.util.Properties ; 30 31 36 public class MonologComponent 37 implements MonologFactory, MonologAttributes { 38 39 private static MonologFactory singleton = Monolog.getDefaultMonologFactory(); 40 41 public static LoggerFactory getLoggerFactory() { 42 return singleton; 43 } 44 45 public static LevelFactory getLevelFactory() { 46 return singleton; 47 } 48 49 public static HandlerFactory getHandlerFactory() { 50 return singleton; 51 } 52 53 54 private MonologFactory factory; 55 private String fileName; 56 57 public MonologComponent() { 58 factory = Monolog.getDefaultMonologFactory(); 59 } 60 61 64 public String getPropertiesFileName() { 65 return fileName; 66 } 67 68 public void setPropertiesFileName(String propfn) { 69 if (fileName != null && fileName.equals(propfn)) 70 return; 71 fileName = propfn; 72 if (propfn != null) { 73 factory = Monolog.getMonologFactory(propfn); 74 if (singleton != Monolog.getDefaultMonologFactory()) { 75 singleton = factory; 76 } 77 } 78 } 79 80 83 public Logger getLogger(String key) { 84 return factory.getLogger(key); 85 } 86 87 public Logger getLogger(String key, String resourceBundleName) { 88 return factory.getLogger(key, resourceBundleName); 89 } 90 91 public String getResourceBundleName() { 92 return factory.getResourceBundleName(); 93 } 94 95 public void setResourceBundleName(String resourceBundleName) { 96 factory.setResourceBundleName(resourceBundleName); 97 } 98 99 public Logger[] getLoggers() { 100 return factory.getLoggers(); 101 } 102 103 104 107 public Level defineLevel(String name, int value) { 108 return factory.defineLevel(name, value); 109 } 110 111 public Level defineLevel(String name, String value) { 112 return factory.defineLevel(name, value); 113 } 114 115 public Level getLevel(String name) { 116 return factory.getLevel(name); 117 } 118 119 public Level getLevel(int value) { 120 return factory.getLevel(value); 121 } 122 123 public Level[] getLevels() { 124 return factory.getLevels(); 125 } 126 127 public void removeLevel(String name) { 128 factory.removeLevel(name); 129 } 130 131 132 135 public Handler createHandler(String hn, String handlertype) { 136 return factory.createHandler(hn, handlertype); 137 } 138 139 public Handler[] getHandlers() { 140 return factory.getHandlers(); 141 } 142 143 public Handler getHandler(String handlername) { 144 return factory.getHandler(handlername); 145 } 146 147 public Handler removeHandler(String handlername) { 148 return factory.removeHandler(handlername); 149 } 150 151 154 public void configure(Properties prop) throws Exception { 155 factory.configure(prop); 156 } 157 } 158 | Popular Tags |