diff --git a/hutool-log/pom.xml b/hutool-log/pom.xml
index c3a2f0430..851b85afd 100755
--- a/hutool-log/pom.xml
+++ b/hutool-log/pom.xml
@@ -26,6 +26,7 @@
2.19.0
1.2
1.3.6
+ 2.6.0
3.4.3.Final
0.44.3
@@ -78,7 +79,7 @@
org.tinylog
tinylog-api
- 2.5.0
+ ${tinylog2.version}
true
@@ -104,7 +105,7 @@
org.tinylog
tinylog-impl
- 2.5.0
+ ${tinylog2.version}
test
diff --git a/hutool-log/src/main/java/cn/hutool/log/dialect/tinylog/TinyLog.java b/hutool-log/src/main/java/cn/hutool/log/dialect/tinylog/TinyLog.java
index 50313054c..8334d4045 100644
--- a/hutool-log/src/main/java/cn/hutool/log/dialect/tinylog/TinyLog.java
+++ b/hutool-log/src/main/java/cn/hutool/log/dialect/tinylog/TinyLog.java
@@ -12,22 +12,33 @@ import cn.hutool.log.AbstractLog;
* tinylog log.
*
* @author Looly
- *
*/
public class TinyLog extends AbstractLog {
private static final long serialVersionUID = -4848042277045993735L;
- /** 堆栈增加层数,因为封装因此多了两层,此值用于正确获取当前类名 */
+ /**
+ * 堆栈增加层数,因为封装因此多了两层,此值用于正确获取当前类名
+ */
private static final int DEPTH = 4;
private final int level;
private final String name;
+ /**
+ * 构造
+ *
+ * @param clazz 类
+ */
// ------------------------------------------------------------------------- Constructor
public TinyLog(final Class> clazz) {
this(null == clazz ? StrUtil.NULL : clazz.getName());
}
+ /**
+ * 构造
+ *
+ * @param name 日志名
+ */
public TinyLog(final String name) {
this.name = name;
this.level = Logger.getLevel(name).ordinal();
@@ -59,6 +70,7 @@ public class TinyLog extends AbstractLog {
public void debug(final String fqcn, final Throwable t, final String format, final Object... arguments) {
logIfEnabled(fqcn, Level.DEBUG, t, format, arguments);
}
+
// ------------------------------------------------------------------------- Info
@Override
public boolean isInfoEnabled() {
@@ -105,15 +117,16 @@ public class TinyLog extends AbstractLog {
/**
* 在对应日志级别打开情况下打印日志
- * @param fqcn 完全限定类名(Fully Qualified Class Name),用于定位日志位置
- * @param level 日志级别
- * @param t 异常,null则检查最后一个参数是否为Throwable类型,是则取之,否则不打印堆栈
- * @param format 日志消息模板
+ *
+ * @param fqcn 完全限定类名(Fully Qualified Class Name),用于定位日志位置
+ * @param level 日志级别
+ * @param t 异常,null则检查最后一个参数是否为Throwable类型,是则取之,否则不打印堆栈
+ * @param format 日志消息模板
* @param arguments 日志消息参数
*/
private void logIfEnabled(final String fqcn, final Level level, Throwable t, final String format, final Object... arguments) {
// fqcn 无效
- if(null == t){
+ if (null == t) {
t = getLastArgumentIfThrowable(arguments);
}
LogEntryForwarder.forward(DEPTH, level, t, StrUtil.toString(format), arguments);
@@ -129,26 +142,26 @@ public class TinyLog extends AbstractLog {
private Level toTinyLevel(final cn.hutool.log.level.Level level) {
final Level tinyLevel;
switch (level) {
- case TRACE:
- tinyLevel = Level.TRACE;
- break;
- case DEBUG:
- tinyLevel = Level.DEBUG;
- break;
- case INFO:
- tinyLevel = Level.INFO;
- break;
- case WARN:
- tinyLevel = Level.WARNING;
- break;
- case ERROR:
- tinyLevel = Level.ERROR;
- break;
- case OFF:
- tinyLevel = Level.OFF;
- break;
- default:
- throw new Error(StrUtil.format("Can not identify level: {}", level));
+ case TRACE:
+ tinyLevel = Level.TRACE;
+ break;
+ case DEBUG:
+ tinyLevel = Level.DEBUG;
+ break;
+ case INFO:
+ tinyLevel = Level.INFO;
+ break;
+ case WARN:
+ tinyLevel = Level.WARNING;
+ break;
+ case ERROR:
+ tinyLevel = Level.ERROR;
+ break;
+ case OFF:
+ tinyLevel = Level.OFF;
+ break;
+ default:
+ throw new Error(StrUtil.format("Can not identify level: {}", level));
}
return tinyLevel;
}
diff --git a/hutool-log/src/main/resources/META-INF/services/cn.hutool.log.LogFactory b/hutool-log/src/main/resources/META-INF/services/cn.hutool.log.LogFactory
index b0bec7baa..eb6ad17c6 100644
--- a/hutool-log/src/main/resources/META-INF/services/cn.hutool.log.LogFactory
+++ b/hutool-log/src/main/resources/META-INF/services/cn.hutool.log.LogFactory
@@ -3,6 +3,6 @@ cn.hutool.log.dialect.slf4j.Slf4jLogFactory
cn.hutool.log.dialect.log4j2.Log4j2LogFactory
cn.hutool.log.dialect.log4j.Log4jLogFactory
cn.hutool.log.dialect.commons.ApacheCommonsLogFactory
-cn.hutool.log.dialect.tinylog.TinyLogFactory
cn.hutool.log.dialect.tinylog.TinyLog2Factory
+cn.hutool.log.dialect.tinylog.TinyLogFactory
cn.hutool.log.dialect.jboss.JbossLogFactory