Skip to content

Commit

Permalink
1.7.0 release and 增加logback支持
Browse files Browse the repository at this point in the history
  • Loading branch information
qq254963746 committed Mar 6, 2017
1 parent 3ef521a commit 2cd6652
Show file tree
Hide file tree
Showing 18 changed files with 197 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ oschina地址:

这两个地址都会同步更新。感兴趣,请加QQ群:109500214 一起探讨、完善。越多人支持,就越有动力去更新,喜欢记得右上角star哈。

##1.7.0-SNAPSHOT(master)变更主要点
##1.7.0(master)变更主要点
1. 增加手动触发任务按钮
2. 优化PreLoader

Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ start mvn clean install -DskipTests
echo "LTS: mvn clean install -DskipTests"
echo "LTS: After sub window finished, close it , and press any key to continue" & pause>nul

set VERSION=1.7.0-SNAPSHOT
set VERSION=1.7.0
set BASE_HOME=%~dp0%
set DIST_BIN_DIR=lts-%VERSION%-bin

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION="1.7.0-SNAPSHOT"
VERSION="1.7.0"

LTS_BIN="${BASH_SOURCE-$0}"
LTS_BIN="$(dirname "${LTS_BIN}")"
Expand Down
4 changes: 2 additions & 2 deletions lts-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
Expand Down Expand Up @@ -215,4 +215,4 @@
<artifactId>mongo-java-driver</artifactId>
</dependency>
</dependencies>
</project>
</project>
9 changes: 7 additions & 2 deletions lts-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down Expand Up @@ -136,5 +136,10 @@
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.ltsopensource.core.logger.jcl.JclLoggerAdapter;
import com.github.ltsopensource.core.logger.jdk.JdkLoggerAdapter;
import com.github.ltsopensource.core.logger.log4j.Log4jLoggerAdapter;
import com.github.ltsopensource.core.logger.logback.LogbackLoggerAdapter;
import com.github.ltsopensource.core.logger.slf4j.Slf4jLoggerAdapter;
import com.github.ltsopensource.core.logger.support.FailsafeLogger;
import com.github.ltsopensource.core.spi.ServiceLoader;
Expand All @@ -28,7 +29,9 @@ private LoggerFactory() {
// 查找常用的日志框架
static {
String logger = System.getProperty("lts.logger");
if ("slf4j".equals(logger)) {
if ("logback".equals(logger)) {
setLoggerAdapter(new LogbackLoggerAdapter());
} else if ("slf4j".equals(logger)) {
setLoggerAdapter(new Slf4jLoggerAdapter());
} else if ("jcl".equals(logger)) {
setLoggerAdapter(new JclLoggerAdapter());
Expand All @@ -38,15 +41,19 @@ private LoggerFactory() {
setLoggerAdapter(new JdkLoggerAdapter());
} else {
try {
setLoggerAdapter(new Slf4jLoggerAdapter());
} catch (Throwable e1) {
setLoggerAdapter(new LogbackLoggerAdapter());
} catch (Throwable e0) {
try {
setLoggerAdapter(new Log4jLoggerAdapter());
} catch (Throwable e2) {
setLoggerAdapter(new Slf4jLoggerAdapter());
} catch (Throwable e1) {
try {
setLoggerAdapter(new JclLoggerAdapter());
} catch (Throwable e3) {
setLoggerAdapter(new JdkLoggerAdapter());
setLoggerAdapter(new Log4jLoggerAdapter());
} catch (Throwable e2) {
try {
setLoggerAdapter(new JclLoggerAdapter());
} catch (Throwable e3) {
setLoggerAdapter(new JdkLoggerAdapter());
}
}
}
}
Expand Down Expand Up @@ -132,4 +139,4 @@ public static File getFile() {
return LOGGER_ADAPTER.getFile();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.github.ltsopensource.core.logger.logback;

import com.github.ltsopensource.core.logger.Logger;
import com.github.ltsopensource.core.logger.support.AbstractLogger;

import java.io.Serializable;

public class LogbackLogger extends AbstractLogger implements Logger, Serializable {

private static final long serialVersionUID = 1L;
private final ch.qos.logback.classic.Logger logger;

public LogbackLogger(ch.qos.logback.classic.Logger logger) {
this.logger = logger;
}

public void trace(String msg) {
logger.trace(msg);
}

public void trace(Throwable e) {
logger.trace(e.getMessage(), e);
}

public void trace(String msg, Throwable e) {
logger.trace(msg, e);
}

public void debug(String msg) {
logger.debug(msg);
}

public void debug(Throwable e) {
logger.debug(e.getMessage(), e);
}

public void debug(String msg, Throwable e) {
logger.debug(msg, e);
}

public void info(String msg) {
logger.info(msg);
}

public void info(Throwable e) {
logger.info(e.getMessage(), e);
}

public void info(String msg, Throwable e) {
logger.info(msg, e);
}

public void warn(String msg) {
logger.warn(msg);
}

public void warn(Throwable e) {
logger.warn(e.getMessage(), e);
}

public void warn(String msg, Throwable e) {
logger.warn(msg, e);
}

public void error(String msg) {
logger.error(msg);
}

public void error(Throwable e) {
logger.error(e.getMessage(), e);
}

public void error(String msg, Throwable e) {
logger.error(msg, e);
}

public boolean isTraceEnabled() {
return logger.isTraceEnabled();
}

public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}

public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}

public boolean isWarnEnabled() {
return logger.isWarnEnabled();
}

public boolean isErrorEnabled() {
return logger.isErrorEnabled();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.github.ltsopensource.core.logger.logback;

import com.github.ltsopensource.core.logger.Level;
import com.github.ltsopensource.core.logger.Logger;
import com.github.ltsopensource.core.logger.LoggerAdapter;
import org.slf4j.LoggerFactory;

import java.io.File;

public class LogbackLoggerAdapter implements LoggerAdapter {

public LogbackLoggerAdapter() {
try {
Class.forName("ch.qos.logback.classic.Logger");
} catch (ClassNotFoundException e) {
throw new RuntimeException("ch.qos.logback.classic.Logger not found");
}
}

public Logger getLogger(String key) {
return new LogbackLogger((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(key));
}

public Logger getLogger(Class<?> key) {
return new LogbackLogger((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(key));
}

private Level level;

private File file;

public void setLevel(Level level) {
this.level = level;
}

public Level getLevel() {
return level;
}

public File getFile() {
return file;
}

public void setFile(File file) {
this.file = file;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private Version() {}

private static final Logger LOGGER = LoggerFactory.getLogger(Version.class);

private static final String VERSION = getVersion(Version.class, "1.7.0-SNAPSHOT");
private static final String VERSION = getVersion(Version.class, "1.7.0");

static {
// 检查是否存在重复的jar包
Expand Down Expand Up @@ -113,4 +113,4 @@ public static void checkDuplicate(String path, boolean failOnError) {
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
slf4j=com.github.ltsopensource.core.logger.slf4j.Slf4jLoggerAdapter
jcl=com.github.ltsopensource.core.logger.jcl.JclLoggerAdapter
log4j=com.github.ltsopensource.core.logger.log4j.Log4jLoggerAdapter
jdk=com.github.ltsopensource.core.logger.jdk.JdkLoggerAdapter
jdk=com.github.ltsopensource.core.logger.jdk.JdkLoggerAdapter
logback=com.github.ltsopensource.core.logger.logback.LogbackLoggerAdapter
4 changes: 2 additions & 2 deletions lts-jobclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -19,4 +19,4 @@
</dependency>
</dependencies>

</project>
</project>
4 changes: 2 additions & 2 deletions lts-jobtracker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -19,4 +19,4 @@
</dependency>
</dependencies>

</project>
</project>
4 changes: 2 additions & 2 deletions lts-monitor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,4 +24,4 @@
</dependency>
</dependencies>

</project>
</project>
4 changes: 2 additions & 2 deletions lts-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down Expand Up @@ -89,4 +89,4 @@
</plugins>
</build>

</project>
</project>
2 changes: 1 addition & 1 deletion lts-startup/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
4 changes: 2 additions & 2 deletions lts-tasktracker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -25,4 +25,4 @@
</dependencies>


</project>
</project>
4 changes: 2 additions & 2 deletions lts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>lts-parent</artifactId>
<groupId>com.github.ltsopensource</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -330,4 +330,4 @@
</plugins>
</build>

</project>
</project>
Loading

0 comments on commit 2cd6652

Please sign in to comment.