Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.cybermkd.log.provider.JdkLoggerProvider Maven / Gradle / Ivy
package com.cybermkd.log.provider;
import com.cybermkd.common.util.Colorer;
import com.cybermkd.log.Logger;
import java.util.logging.Level;
/**
* Created by ice on 15-1-5.
*/
public class JdkLoggerProvider implements LoggerProvider {
public Logger getLogger(Class clazz) {
return new JdkLogger(java.util.logging.Logger.getLogger(clazz.getName()));
}
public Logger getLogger(String clazzName) {
return new JdkLogger(java.util.logging.Logger.getLogger(clazzName));
}
public class JdkLogger extends Logger {
private java.util.logging.Logger logger;
private String clazzName;
JdkLogger(java.util.logging.Logger logger) {
this.logger = logger;
}
public void debug(String message) {
logger.logp(Level.FINE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.cyan(message));
}
public void debug(String message, Throwable t) {
logger.logp(Level.FINE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.cyan(message), t);
}
public void debug(String message, Object... args) {
logger.logp(Level.FINE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.cyan(String.format(message, args)));
}
public void debug(String message, Throwable t, Object... args) {
logger.logp(Level.FINE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.cyan(String.format(message, args)), t);
}
public void info(String message) {
logger.logp(Level.INFO, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.blue(message));
}
public void info(String message, Throwable t) {
logger.logp(Level.INFO, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.blue(message), t);
}
public void info(String message, Object... args) {
logger.logp(Level.INFO, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.blue(String.format(message, args)));
}
public void info(String message, Throwable t, Object... args) {
logger.logp(Level.INFO, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.blue(String.format(message, args)), t);
}
public void warn(String message) {
logger.logp(Level.WARNING, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.yellow(message));
}
public void warn(String message, Throwable t) {
logger.logp(Level.WARNING, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.yellow(message), t);
}
public void warn(String message, Object... args) {
logger.logp(Level.WARNING, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.yellow(String.format(message, args)));
}
public void warn(String message, Throwable t, Object... args) {
logger.logp(Level.WARNING, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.yellow(String.format(message, args)), t);
}
public void error(String message) {
logger.logp(Level.SEVERE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.red(message));
}
public void error(String message, Throwable t) {
logger.logp(Level.SEVERE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.red(message), t);
}
public void error(String message, Object... args) {
logger.logp(Level.SEVERE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.red(String.format(message, args)));
}
public void error(String message, Throwable t, Object... args) {
logger.logp(Level.SEVERE, clazzName, Thread.currentThread().getStackTrace()[1].getMethodName(), Colorer.red(String.format(message, args)), t);
}
public boolean isDebugEnabled() {
return logger.isLoggable(Level.FINE);
}
public boolean isInfoEnabled() {
return logger.isLoggable(Level.INFO);
}
public boolean isWarnEnabled() {
return logger.isLoggable(Level.WARNING);
}
public boolean isErrorEnabled() {
return logger.isLoggable(Level.SEVERE);
}
}
}