下面列出了java.util.logging.Logger#logp ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void log(Level level, Logger logger, String message) {
if (this.toString().startsWith("LOG_")) {
logger.log(level, message);
} else if (this.toString().startsWith("LOG1_")) {
logger.log(level, message, "dummy param");
} else if (this.toString().startsWith("LOG2_")) {
logger.log(level, message, new Object[] {"dummy", "param"});
} else if (this.toString().startsWith("LOG3_")) {
logger.log(level, message, new Exception("dummy exception"));
} else if (this.toString().startsWith("LOGP_")) {
logger.logp(level, "TestCase", "log", message);
} else if (this.toString().startsWith("LOGP1_")) {
logger.logp(level, "TestCase", "log", message, "dummy param");
} else if (this.toString().startsWith("LOGP2_")) {
logger.logp(level, "TestCase", "log", message,
new Object[] {"dummy", "param"});
} else if (this.toString().startsWith("LOGP3_")) {
logger.logp(level, "TestCase", "log", message,
new Exception("dummy exception"));
} else if (this.toString().startsWith("LEV_")) {
loglevel(level, logger, message);
}
}
public void log(Level level, Logger logger, String message) {
if (this.toString().startsWith("LOG_")) {
logger.log(level, message);
} else if (this.toString().startsWith("LOG1_")) {
logger.log(level, message, "dummy param");
} else if (this.toString().startsWith("LOG2_")) {
logger.log(level, message, new Object[] {"dummy", "param"});
} else if (this.toString().startsWith("LOG3_")) {
logger.log(level, message, new Exception("dummy exception"));
} else if (this.toString().startsWith("LOGP_")) {
logger.logp(level, "TestCase", "log", message);
} else if (this.toString().startsWith("LOGP1_")) {
logger.logp(level, "TestCase", "log", message, "dummy param");
} else if (this.toString().startsWith("LOGP2_")) {
logger.logp(level, "TestCase", "log", message,
new Object[] {"dummy", "param"});
} else if (this.toString().startsWith("LOGP3_")) {
logger.logp(level, "TestCase", "log", message,
new Exception("dummy exception"));
} else if (this.toString().startsWith("LEV_")) {
loglevel(level, logger, message);
}
}
public void log(Level level, Logger logger, String message) {
if (this.toString().startsWith("LOG_")) {
logger.log(level, message);
} else if (this.toString().startsWith("LOG1_")) {
logger.log(level, message, "dummy param");
} else if (this.toString().startsWith("LOG2_")) {
logger.log(level, message, new Object[] {"dummy", "param"});
} else if (this.toString().startsWith("LOG3_")) {
logger.log(level, message, new Exception("dummy exception"));
} else if (this.toString().startsWith("LOGP_")) {
logger.logp(level, "TestCase", "log", message);
} else if (this.toString().startsWith("LOGP1_")) {
logger.logp(level, "TestCase", "log", message, "dummy param");
} else if (this.toString().startsWith("LOGP2_")) {
logger.logp(level, "TestCase", "log", message,
new Object[] {"dummy", "param"});
} else if (this.toString().startsWith("LOGP3_")) {
logger.logp(level, "TestCase", "log", message,
new Exception("dummy exception"));
} else if (this.toString().startsWith("LEV_")) {
loglevel(level, logger, message);
}
}
public void debug(String func, Throwable t) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINEST,className,
func,t.toString(),t);
}
public void trace(String func, String msg, Throwable t) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,msg,t);
}
public void error(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.SEVERE,className,
func,msg);
}
public void trace(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,msg);
}
public void debug(String func, Throwable t) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINEST,className,
func,t.toString(),t);
}
public void debug(String func, String msg, Throwable t) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINEST,className,
func,msg,t);
}
@Ignore
@Test
public void test() {
Logger logger = Logger.getLogger(this.getClass().getName());
logger.info("tset");
// formatting is not supported
logger.log(Level.INFO, "Test %s", "sdfsdf");
logger.log(Level.INFO, "Test ", new Exception());
logger.logp(Level.INFO, JdkLoggerTest.class.getName(), "test()", "tsdd");
// Should not log this because log level for test defined in logging.properties is "fine".
logger.finest("logged?");
}
public void trace(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,msg);
}
public void trace(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,msg);
}
public void trace(String func, String msg, Throwable t) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,msg,t);
}
public void config(String func, Throwable t) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.CONFIG,className,
func,t.toString(),t);
}
public void error(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.SEVERE,className,
func,msg);
}
public void trace(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,msg);
}
public void trace(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,msg);
}
public void error(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.SEVERE,className,
func,msg);
}
public void trace(String func, Throwable t) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINE,className,
func,t.toString(),t);
}
public void debug(String func, String msg) {
final Logger l = getLogger();
if (l!=null) l.logp(Level.FINEST,className,
func,msg);
}