fix log bug

This commit is contained in:
Looly
2020-09-16 13:52:26 +08:00
parent 667dbc2be7
commit f9f73e4c02
7 changed files with 59 additions and 12 deletions

View File

@@ -18,7 +18,7 @@
<properties>
<!-- versions -->
<slf4j.version>1.7.26</slf4j.version>
<slf4j.version>1.7.30</slf4j.version>
<logback.version>1.3.0-alpha5</logback.version>
<log4j.version>1.2.17</log4j.version>
<log4j2.version>2.13.3</log4j2.version>
@@ -77,5 +77,11 @@
<version>${jboss-logging.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -120,6 +120,7 @@ public class ConsoleLog extends AbstractLog {
return;
}
final Dict dict = Dict.create()
.set("date", DateUtil.now())
.set("level", level.toString())

View File

@@ -116,7 +116,7 @@ public class TinyLog extends AbstractLog {
if(null == t){
t = getLastArgumentIfThrowable(arguments);
}
LogEntryForwarder.forward(DEPTH, level, t, format, arguments);
LogEntryForwarder.forward(DEPTH, level, t, StrUtil.toString(format), arguments);
}
/**

View File

@@ -28,9 +28,18 @@ public class CustomLogTest {
LogFactory.setCurrentLogFactory(factory);
Log log = LogFactory.get();
log.info(null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
@Test
public void consoleLogNullTest(){
LogFactory factory = new ConsoleLogFactory();
LogFactory.setCurrentLogFactory(factory);
Log log = LogFactory.get();
log.info(null);
log.info((String)null);
}
@Test
public void commonsLogTest(){
@@ -39,6 +48,7 @@ public class CustomLogTest {
Log log = LogFactory.get();
log.info(null);
log.info((String)null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
@@ -49,6 +59,7 @@ public class CustomLogTest {
Log log = LogFactory.get();
log.info(null);
log.info((String)null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
@@ -61,6 +72,7 @@ public class CustomLogTest {
log.debug(null);
log.debug("This is custom '{}' log\n{}", factory.getName(), LINE);
log.info(null);
log.info((String)null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
@@ -71,6 +83,7 @@ public class CustomLogTest {
Log log = LogFactory.get();
log.info(null);
log.info((String)null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
@@ -82,6 +95,7 @@ public class CustomLogTest {
Log log = LogFactory.get();
log.info(null);
log.info((String)null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
@@ -92,6 +106,7 @@ public class CustomLogTest {
Log log = LogFactory.get();
log.info(null);
log.info((String)null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
@@ -102,6 +117,7 @@ public class CustomLogTest {
Log log = LogFactory.get();
log.info(null);
log.info((String)null);
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
}
}

View File

@@ -37,4 +37,12 @@ public class LogTest {
Exception e = new Exception("test Exception");
log.error("我是错误消息", e);
}
@Test
public void logNullTest(){
final Log log = Log.get();
log.debug(null);
log.info(null);
log.warn(null);
}
}