1 42 43 package org.jfree.base.log; 44 45 import org.jfree.util.Log; 46 import org.jfree.util.LogTarget; 47 import org.jfree.util.PrintStreamLogTarget; 48 49 55 public class DefaultLog extends Log { 56 57 58 private static final PrintStreamLogTarget DEFAULT_LOG_TARGET = 59 new PrintStreamLogTarget(); 60 61 62 private static final DefaultLog defaultLogInstance; 63 64 67 protected DefaultLog () { 68 } 70 71 static { 72 defaultLogInstance = new DefaultLog(); 73 defaultLogInstance.addTarget(DEFAULT_LOG_TARGET); 74 try { 75 final String property = System.getProperty("org.jfree.DebugDefault", "false"); 78 if (Boolean.valueOf(property).booleanValue()) { 79 defaultLogInstance.setDebuglevel(LogTarget.DEBUG); 80 } 81 else { 82 defaultLogInstance.setDebuglevel(LogTarget.WARN); 83 } 84 } 85 catch (SecurityException se) { 86 defaultLogInstance.setDebuglevel(LogTarget.WARN); 87 } 88 } 89 90 94 public void init() { 95 removeTarget(DEFAULT_LOG_TARGET); 96 final String logLevel = LogConfiguration.getLogLevel(); 97 if (logLevel.equalsIgnoreCase("error")) { 98 setDebuglevel(LogTarget.ERROR); 99 } 100 else if (logLevel.equalsIgnoreCase("warn")) { 101 setDebuglevel(LogTarget.WARN); 102 } 103 else if (logLevel.equalsIgnoreCase("info")) { 104 setDebuglevel(LogTarget.INFO); 105 } 106 else if (logLevel.equalsIgnoreCase("debug")) { 107 setDebuglevel(LogTarget.DEBUG); 108 } 109 } 110 111 117 public synchronized void addTarget(final LogTarget target) 118 { 119 super.addTarget(target); 120 if (target != DEFAULT_LOG_TARGET) { 124 removeTarget(DEFAULT_LOG_TARGET); 125 } 126 } 127 128 133 public static DefaultLog getDefaultLog() { 134 return defaultLogInstance; 135 } 136 137 140 public static void installDefaultLog () { 141 Log.defineLog(defaultLogInstance); 142 } 143 } 144 | Popular Tags |