123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package cn.com.qmth.examcloud.commons.logging;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.slf4j.spi.LocationAwareLogger;
- /**
- * slf4j
- *
- * @author WANGWEI
- */
- public class SLF4JImpl implements ExamCloudLog {
- /**
- * 属性注释
- */
- private static final String callerFQCN = SLF4JImpl.class.getName();
- /**
- * 属性注释
- */
- private static final Logger testLogger = LoggerFactory.getLogger(SLF4JImpl.class);
- /**
- * 属性注释
- */
- private LocationAwareLogger log;
- static {
- if (!(testLogger instanceof LocationAwareLogger)) {
- throw new UnsupportedOperationException(testLogger.getClass() + " is not a suitable logger");
- }
- }
- /**
- * 构造函数
- *
- * @param log
- */
- public SLF4JImpl(LocationAwareLogger log) {
- this.log = log;
- }
- /**
- * 构造函数
- */
- public SLF4JImpl(String loggerName) {
- this.log = (LocationAwareLogger) LoggerFactory.getLogger(loggerName);
- }
- @Override
- public boolean isDebugEnabled() {
- return log.isDebugEnabled();
- }
- @Override
- public void debug(String msg) {
- log.log(null, callerFQCN, LocationAwareLogger.DEBUG_INT, msg, null, null);
- }
- @Override
- public void debug(String msg, Throwable e) {
- log.log(null, callerFQCN, LocationAwareLogger.ERROR_INT, msg, null, e);
- }
- @Override
- public boolean isInfoEnabled() {
- return log.isInfoEnabled();
- }
- @Override
- public void info(String msg) {
- log.log(null, callerFQCN, LocationAwareLogger.INFO_INT, msg, null, null);
- }
- @Override
- public void info(String msg, Throwable t) {
- log.log(null, callerFQCN, LocationAwareLogger.INFO_INT, msg, null, t);
- }
- @Override
- public boolean isWarnEnabled() {
- return log.isWarnEnabled();
- }
- @Override
- public void warn(String msg) {
- log.log(null, callerFQCN, LocationAwareLogger.WARN_INT, msg, null, null);
- }
- @Override
- public void warn(String msg, Throwable t) {
- log.log(null, callerFQCN, LocationAwareLogger.WARN_INT, msg, null, t);
- }
- @Override
- public boolean isErrorEnabled() {
- return log.isErrorEnabled();
- }
- @Override
- public void error(String msg) {
- log.log(null, callerFQCN, LocationAwareLogger.ERROR_INT, msg, null, null);
- }
- @Override
- public void error(String msg, Throwable t) {
- log.log(null, callerFQCN, LocationAwareLogger.ERROR_INT, msg, null, t);
- }
- }
|