1 20 21 package org.snmp4j.log; 22 23 import java.util.*; 24 25 34 public class LogProxy implements LogAdapter { 35 36 private String name; 37 private LogAdapter logger; 38 39 public LogProxy(String name) { 40 this.name = name; 41 } 42 43 public LogProxy(LogAdapter logger) { 44 this.logger = logger; 45 } 46 47 public void debug(Object message) { 48 if (logger != null) { 49 logger.debug(message); 50 } 51 } 52 53 public void error(Object message) { 54 if (logger != null) { 55 logger.error(message); 56 } 57 } 58 59 public void error(Object message, Throwable throwable) { 60 if (logger != null) { 61 logger.error(message, throwable); 62 } 63 } 64 65 public void fatal(Object message) { 66 if (logger != null) { 67 logger.fatal(message); 68 } 69 } 70 71 public void fatal(Object message, Throwable throwable) { 72 if (logger != null) { 73 logger.fatal(message, throwable); 74 } 75 } 76 77 public LogLevel getEffectiveLogLevel() { 78 if (logger != null) { 79 return logger.getEffectiveLogLevel(); 80 } 81 return LogLevel.OFF; 82 } 83 84 public Iterator getLogHandler() { 85 if (logger != null) { 86 return logger.getLogHandler(); 87 } 88 return Collections.EMPTY_LIST.iterator(); 89 } 90 91 public LogLevel getLogLevel() { 92 if (logger != null) { 93 return logger.getLogLevel(); 94 } 95 return LogLevel.OFF; 96 } 97 98 public String getName() { 99 if (logger != null) { 100 logger.getName(); 101 } 102 return name; 103 } 104 105 public void info(Object message) { 106 if (logger != null) { 107 logger.info(message); 108 } 109 } 110 111 public boolean isDebugEnabled() { 112 if (logger != null) { 113 return logger.isDebugEnabled(); 114 } 115 return false; 116 } 117 118 public boolean isInfoEnabled() { 119 if (logger != null) { 120 return logger.isInfoEnabled(); 121 } 122 return false; 123 } 124 125 public boolean isWarnEnabled() { 126 if (logger != null) { 127 return logger.isWarnEnabled(); 128 } 129 return false; 130 } 131 132 public void setLogLevel(LogLevel level) { 133 if (logger != null) { 134 logger.setLogLevel(level); 135 } 136 } 137 138 public void warn(Object message) { 139 if (logger != null) { 140 logger.warn(message); 141 } 142 } 143 144 149 public LogAdapter getLogger() { 150 return logger; 151 } 152 153 158 public void setLogger(LogAdapter logger) { 159 this.logger = logger; 160 } 161 } 162 | Popular Tags |