StaticLog rename to LogUtil

This commit is contained in:
Looly
2023-05-15 20:03:12 +08:00
parent d0556a4e48
commit 4670f21a8c
22 changed files with 98 additions and 56 deletions

View File

@@ -62,7 +62,7 @@ import java.util.function.Supplier;
* <li>去除两边的指定所有字符trim</li> * <li>去除两边的指定所有字符trim</li>
* <li>去除两边的指定所有字符包装和去除包装wrap</li> * <li>去除两边的指定所有字符包装和去除包装wrap</li>
* </ul> * </ul>
* * <p>
* 需要注意的是strip、trim、wrapunWrap的策略不同 * 需要注意的是strip、trim、wrapunWrap的策略不同
* <ul> * <ul>
* <li>strip 强调去除两边或某一边的指定字符串,这个字符串不会重复去除,如果一边不存在,另一边不影响去除</li> * <li>strip 强调去除两边或某一边的指定字符串,这个字符串不会重复去除,如果一边不存在,另一边不影响去除</li>
@@ -1538,12 +1538,22 @@ public class CharSequenceUtil extends StrValidator {
/** /**
* 截取字符串,从指定位置开始,截取指定长度的字符串<br> * 截取字符串,从指定位置开始,截取指定长度的字符串<br>
* author weibaohui * 当fromIndex为正数时这个index指的是插空位置如下
* <pre>
* 0 1 2 3 4
* A B C D
* </pre>
* 当fromIndex为负数时为反向插空位置其中-1表示最后一个字符之前的位置
* <pre>
* -3 -2 -1 length
* A B C D
* </pre>
* *
* @param input 原始字符串 * @param input 原始字符串
* @param fromIndex 开始的index,包括 * @param fromIndex 开始的index,包括,可以为负数
* @param length 要截取的长度 * @param length 要截取的长度
* @return 截取后的字符串 * @return 截取后的字符串
* author weibaohui
*/ */
public static String subByLength(final String input, final int fromIndex, final int length) { public static String subByLength(final String input, final int fromIndex, final int length) {
if (isEmpty(input)) { if (isEmpty(input)) {

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 looly(loolly@aliyun.com)
* Hutool is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
package org.dromara.hutool.core.text;
import org.dromara.hutool.core.lang.Console;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class IssueI73AB9Test {
/**
* https://gitee.com/dromara/hutool/issues/I73AB9
*/
@Test
void subWithLengthTest() {
final String str = "7814A103447E";
String s = StrUtil.subByLength(str, -4, 2);
Assertions.assertEquals("03", s);
s = StrUtil.subByLength(str, -2, 2);
Assertions.assertEquals("44", s);
}
}

View File

@@ -24,7 +24,7 @@ import org.dromara.hutool.cron.pattern.CronPattern;
import org.dromara.hutool.cron.task.InvokeTask; import org.dromara.hutool.cron.task.InvokeTask;
import org.dromara.hutool.cron.task.RunnableTask; import org.dromara.hutool.cron.task.RunnableTask;
import org.dromara.hutool.cron.task.Task; import org.dromara.hutool.cron.task.Task;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import org.dromara.hutool.setting.Setting; import org.dromara.hutool.setting.Setting;
import java.io.Serializable; import java.io.Serializable;
@@ -221,7 +221,7 @@ public class Scheduler implements Serializable {
jobClass = group + CharUtil.DOT + jobClass; jobClass = group + CharUtil.DOT + jobClass;
} }
final String pattern = entry.getValue(); final String pattern = entry.getValue();
StaticLog.debug("Load job: {} {}", pattern, jobClass); LogUtil.debug("Load job: {} {}", pattern, jobClass);
try { try {
// issue#I5E7BM@Gitee自定义ID避免重复从配置文件加载 // issue#I5E7BM@Gitee自定义ID避免重复从配置文件加载
schedule("id_" + jobClass, pattern, new InvokeTask(jobClass)); schedule("id_" + jobClass, pattern, new InvokeTask(jobClass));

View File

@@ -13,7 +13,7 @@
package org.dromara.hutool.cron.listener; package org.dromara.hutool.cron.listener;
import org.dromara.hutool.cron.TaskExecutor; import org.dromara.hutool.cron.TaskExecutor;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
@@ -95,7 +95,7 @@ public class TaskListenerManager implements Serializable {
listener.onFailed(executor, exception); listener.onFailed(executor, exception);
} }
}else{ }else{
StaticLog.error(exception, exception.getMessage()); LogUtil.error(exception, exception.getMessage());
} }
} }
} }

View File

@@ -12,7 +12,7 @@
package org.dromara.hutool.cron.timingwheel; package org.dromara.hutool.cron.timingwheel;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -108,7 +108,7 @@ public class TimingWheel {
//当前时间轮可以容纳该任务 加入时间槽 //当前时间轮可以容纳该任务 加入时间槽
final long virtualId = expiration / tickMs; final long virtualId = expiration / tickMs;
final int index = (int) (virtualId % wheelSize); final int index = (int) (virtualId % wheelSize);
StaticLog.debug("tickMs: {} ------index: {} ------expiration: {}", tickMs, index, expiration); LogUtil.debug("tickMs: {} ------index: {} ------expiration: {}", tickMs, index, expiration);
final TimerTaskList timerTaskList = timerTaskLists[index]; final TimerTaskList timerTaskList = timerTaskLists[index];
timerTaskList.addTask(timerTask); timerTaskList.addTask(timerTask);

View File

@@ -17,7 +17,7 @@ import org.dromara.hutool.db.dialect.Dialect;
import org.dromara.hutool.db.dialect.DialectFactory; import org.dromara.hutool.db.dialect.DialectFactory;
import org.dromara.hutool.db.ds.DSUtil; import org.dromara.hutool.db.ds.DSUtil;
import org.dromara.hutool.db.transaction.TransactionLevel; import org.dromara.hutool.db.transaction.TransactionLevel;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
@@ -190,7 +190,7 @@ public class Db extends AbstractDb<Db> {
try { try {
conn.rollback(); conn.rollback();
} catch (final Exception e) { } catch (final Exception e) {
StaticLog.error(e); LogUtil.error(e);
} }
} }
} }
@@ -206,7 +206,7 @@ public class Db extends AbstractDb<Db> {
try { try {
conn.setAutoCommit(autoCommit); conn.setAutoCommit(autoCommit);
} catch (final Exception e) { } catch (final Exception e) {
StaticLog.error(e); LogUtil.error(e);
} }
} }
} }

View File

@@ -24,7 +24,7 @@ import org.dromara.hutool.db.dialect.impl.PhoenixDialect;
import org.dromara.hutool.db.dialect.impl.PostgresqlDialect; import org.dromara.hutool.db.dialect.impl.PostgresqlDialect;
import org.dromara.hutool.db.dialect.impl.SqlServer2012Dialect; import org.dromara.hutool.db.dialect.impl.SqlServer2012Dialect;
import org.dromara.hutool.db.dialect.impl.Sqlite3Dialect; import org.dromara.hutool.db.dialect.impl.Sqlite3Dialect;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
@@ -51,7 +51,7 @@ public class DialectFactory implements DriverNamePool {
*/ */
public static Dialect newDialect(final String driverName) { public static Dialect newDialect(final String driverName) {
final Dialect dialect = internalNewDialect(driverName); final Dialect dialect = internalNewDialect(driverName);
StaticLog.debug("Use Dialect: [{}].", dialect.getClass().getSimpleName()); LogUtil.debug("Use Dialect: [{}].", dialect.getClass().getSimpleName());
return dialect; return dialect;
} }

View File

@@ -16,7 +16,7 @@ import org.dromara.hutool.core.reflect.ConstructorUtil;
import org.dromara.hutool.core.spi.ListServiceLoader; import org.dromara.hutool.core.spi.ListServiceLoader;
import org.dromara.hutool.db.DbRuntimeException; import org.dromara.hutool.db.DbRuntimeException;
import org.dromara.hutool.db.GlobalDbConfig; import org.dromara.hutool.db.GlobalDbConfig;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import org.dromara.hutool.setting.Setting; import org.dromara.hutool.setting.Setting;
import javax.naming.InitialContext; import javax.naming.InitialContext;
@@ -42,7 +42,7 @@ public class DSUtil {
try { try {
return getJndiDS(jndiName); return getJndiDS(jndiName);
} catch (final DbRuntimeException e) { } catch (final DbRuntimeException e) {
StaticLog.error(e.getCause(), "Find JNDI datasource error!"); LogUtil.error(e.getCause(), "Find JNDI datasource error!");
} }
return null; return null;
} }
@@ -108,7 +108,7 @@ public class DSUtil {
*/ */
public static DSFactory createFactory(final Setting setting) { public static DSFactory createFactory(final Setting setting) {
final DSFactory dsFactory = _createFactory(setting); final DSFactory dsFactory = _createFactory(setting);
StaticLog.debug("Use [{}] DataSource As Default.", dsFactory.getDataSourceName()); LogUtil.debug("Use [{}] DataSource As Default.", dsFactory.getDataSourceName());
return dsFactory; return dsFactory;
} }

View File

@@ -14,7 +14,7 @@ package org.dromara.hutool.db.ds;
import org.dromara.hutool.core.io.IoUtil; import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.util.RuntimeUtil; import org.dromara.hutool.core.util.RuntimeUtil;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
/** /**
* 全局单例数据源工厂<br> * 全局单例数据源工厂<br>
@@ -36,7 +36,7 @@ public class GlobalDSFactory {
RuntimeUtil.addShutdownHook(()->{ RuntimeUtil.addShutdownHook(()->{
if (null != factory) { if (null != factory) {
IoUtil.closeQuietly(factory); IoUtil.closeQuietly(factory);
StaticLog.debug("DataSource: [{}] closed.", factory.getDataSourceName()); LogUtil.debug("DataSource: [{}] closed.", factory.getDataSourceName());
factory = null; factory = null;
} }
}); });
@@ -83,7 +83,7 @@ public class GlobalDSFactory {
IoUtil.closeQuietly(factory); IoUtil.closeQuietly(factory);
} }
StaticLog.debug("Custom use [{}] DataSource.", customDSFactory.getDataSourceName()); LogUtil.debug("Custom use [{}] DataSource.", customDSFactory.getDataSourceName());
factory = customDSFactory; factory = customDSFactory;
} }
return factory; return factory;

View File

@@ -2,7 +2,7 @@ package org.dromara.hutool.db;
import org.dromara.hutool.db.handler.EntityListHandler; import org.dromara.hutool.db.handler.EntityListHandler;
import org.dromara.hutool.db.sql.Condition; import org.dromara.hutool.db.sql.Condition;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -119,7 +119,7 @@ public class DbTest {
Condition.parse("age", "< 100") Condition.parse("age", "< 100")
); );
for (final Entity entity : find) { for (final Entity entity : find) {
StaticLog.debug("{}", entity); LogUtil.debug("{}", entity);
} }
Assertions.assertEquals("unitTestUser", find.get(0).get("name")); Assertions.assertEquals("unitTestUser", find.get(0).get("name"));
} }

View File

@@ -16,7 +16,7 @@ import org.dromara.hutool.core.lang.Singleton;
import org.dromara.hutool.core.spi.SpiUtil; import org.dromara.hutool.core.spi.SpiUtil;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.extra.pinyin.PinyinException; import org.dromara.hutool.extra.pinyin.PinyinException;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
/** /**
* 简单拼音引擎工厂用于根据用户引入的拼音库jar自动创建对应的拼音引擎对象<br> * 简单拼音引擎工厂用于根据用户引入的拼音库jar自动创建对应的拼音引擎对象<br>
@@ -43,7 +43,7 @@ public class PinyinEngineFactory {
*/ */
public static PinyinEngine createEngine() { public static PinyinEngine createEngine() {
final PinyinEngine engine = doCreateEngine(); final PinyinEngine engine = doCreateEngine();
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); LogUtil.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;
} }

View File

@@ -18,7 +18,7 @@ import org.dromara.hutool.core.spi.SpiUtil;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.extra.template.TemplateConfig; import org.dromara.hutool.extra.template.TemplateConfig;
import org.dromara.hutool.extra.template.TemplateException; import org.dromara.hutool.extra.template.TemplateException;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
/** /**
* 简单模板引擎工厂用于根据用户引入的模板引擎jar自动创建对应的模板引擎对象<br> * 简单模板引擎工厂用于根据用户引入的模板引擎jar自动创建对应的模板引擎对象<br>
@@ -58,7 +58,7 @@ public class TemplateEngineFactory {
*/ */
public static TemplateEngine createEngine(final TemplateConfig config) { public static TemplateEngine createEngine(final TemplateConfig config) {
final TemplateEngine engine = doCreateEngine(config); final TemplateEngine engine = doCreateEngine(config);
StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); LogUtil.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;
} }

View File

@@ -16,7 +16,7 @@ import org.dromara.hutool.core.lang.Singleton;
import org.dromara.hutool.core.spi.SpiUtil; import org.dromara.hutool.core.spi.SpiUtil;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.extra.tokenizer.TokenizerException; import org.dromara.hutool.extra.tokenizer.TokenizerException;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
/** /**
* 简单分词引擎工厂用于根据用户引入的分词引擎jar自动创建对应的引擎 * 简单分词引擎工厂用于根据用户引入的分词引擎jar自动创建对应的引擎
@@ -42,7 +42,7 @@ public class TokenizerEngineFactory {
*/ */
public static TokenizerEngine createEngine() { public static TokenizerEngine createEngine() {
final TokenizerEngine engine = doCreateEngine(); final TokenizerEngine engine = doCreateEngine();
StaticLog.debug("Use [{}] Tokenizer Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); LogUtil.debug("Use [{}] Tokenizer Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;
} }

View File

@@ -17,7 +17,7 @@ import org.dromara.hutool.core.spi.SpiUtil;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.http.HttpException; import org.dromara.hutool.http.HttpException;
import org.dromara.hutool.http.client.ClientConfig; import org.dromara.hutool.http.client.ClientConfig;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
/** /**
* Http客户端引擎工厂类 * Http客户端引擎工厂类
@@ -56,7 +56,7 @@ public class ClientEngineFactory {
*/ */
public static ClientEngine createEngine() { public static ClientEngine createEngine() {
final ClientEngine engine = doCreateEngine(); final ClientEngine engine = doCreateEngine();
StaticLog.debug("Use [{}] Http Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine")); LogUtil.debug("Use [{}] Http Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
return engine; return engine;
} }

View File

@@ -21,8 +21,8 @@ import org.dromara.hutool.log.level.Level;
* *
* @author Looly * @author Looly
*/ */
public class StaticLog { public class LogUtil {
private static final String FQCN = StaticLog.class.getName(); private static final String FQCN = LogUtil.class.getName();
// ----------------------------------------------------------- Log method start // ----------------------------------------------------------- Log method start
// ------------------------ Trace // ------------------------ Trace

View File

@@ -6,29 +6,29 @@ import org.dromara.hutool.log.engine.console.ConsoleLogEngine;
import org.dromara.hutool.log.engine.log4j2.Log4j2LogEngine; import org.dromara.hutool.log.engine.log4j2.Log4j2LogEngine;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class StaticLogTest { public class LogUtilTest {
@Test @Test
public void staticLog4j2Test() { public void staticLog4j2Test() {
LogEngineFactory.setDefaultEngine(Log4j2LogEngine.class); LogEngineFactory.setDefaultEngine(Log4j2LogEngine.class);
StaticLog.debug("This is static {} log", "debug"); LogUtil.debug("This is static {} log", "debug");
StaticLog.info("This is static {} log", "info"); LogUtil.info("This is static {} log", "info");
} }
@Test @Test
public void test() { public void test() {
LogEngineFactory.setDefaultEngine(ConsoleLogEngine.class); LogEngineFactory.setDefaultEngine(ConsoleLogEngine.class);
StaticLog.debug("This is static {} log", "debug"); LogUtil.debug("This is static {} log", "debug");
StaticLog.info("This is static {} log", "info"); LogUtil.info("This is static {} log", "info");
} }
@Test @Test
public void colorTest(){ public void colorTest(){
LogEngineFactory.setDefaultEngine(ConsoleColorLogEngine.class); LogEngineFactory.setDefaultEngine(ConsoleColorLogEngine.class);
StaticLog.debug("This is static {} log", "debug"); LogUtil.debug("This is static {} log", "debug");
StaticLog.info("This is static {} log", "info"); LogUtil.info("This is static {} log", "info");
StaticLog.error("This is static {} log", "error"); LogUtil.error("This is static {} log", "error");
StaticLog.warn("This is static {} log", "warn"); LogUtil.warn("This is static {} log", "warn");
StaticLog.trace("This is static {} log", "trace"); LogUtil.trace("This is static {} log", "trace");
} }
} }

View File

@@ -27,7 +27,7 @@ import org.dromara.hutool.core.func.SerSupplier;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.text.CharUtil; import org.dromara.hutool.core.text.CharUtil;
import org.dromara.hutool.core.util.CharsetUtil; import org.dromara.hutool.core.util.CharsetUtil;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import org.dromara.hutool.setting.props.Props; import org.dromara.hutool.setting.props.Props;
import java.io.File; import java.io.File;
@@ -232,7 +232,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
} }
}); });
this.watchMonitor.start(); this.watchMonitor.start();
StaticLog.debug("Auto load for [{}] listenning...", this.resource.getUrl()); LogUtil.debug("Auto load for [{}] listenning...", this.resource.getUrl());
} else { } else {
IoUtil.closeQuietly(this.watchMonitor); IoUtil.closeQuietly(this.watchMonitor);
this.watchMonitor = null; this.watchMonitor = null;
@@ -273,7 +273,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
public Object getObjByGroup(final CharSequence key, final CharSequence group, final Object defaultValue) { public Object getObjByGroup(final CharSequence key, final CharSequence group, final Object defaultValue) {
final String result = this.groupedMap.get(group, key); final String result = this.groupedMap.get(group, key);
if (result == null && logIfNull) { if (result == null && logIfNull) {
StaticLog.debug("No key [{}] in group [{}] !", key, group); LogUtil.debug("No key [{}] in group [{}] !", key, group);
} }
return result; return result;
} }

View File

@@ -33,7 +33,7 @@ import org.dromara.hutool.core.reflect.ConstructorUtil;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.CharsetUtil; import org.dromara.hutool.core.util.CharsetUtil;
import org.dromara.hutool.core.util.ObjUtil; import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -360,7 +360,7 @@ public final class Props extends Properties implements TypeGetter<CharSequence>
BeanUtil.setProperty(bean, StrUtil.subSuf(key, prefix.length()), entry.getValue()); BeanUtil.setProperty(bean, StrUtil.subSuf(key, prefix.length()), entry.getValue());
} catch (final Exception e) { } catch (final Exception e) {
// 忽略注入失败的字段(这些字段可能用于其它配置) // 忽略注入失败的字段(这些字段可能用于其它配置)
StaticLog.debug("Ignore property: [{}],because of: {}", key, e); LogUtil.debug("Ignore property: [{}],because of: {}", key, e);
} }
} }

View File

@@ -16,7 +16,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel; import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler; import java.nio.channels.CompletionHandler;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
/** /**
* 接入完成回调,单例使用 * 接入完成回调,单例使用
@@ -43,7 +43,7 @@ public class AcceptHandler implements CompletionHandler<AsynchronousSocketChanne
@Override @Override
public void failed(final Throwable exc, final AioServer aioServer) { public void failed(final Throwable exc, final AioServer aioServer) {
StaticLog.error(exc); LogUtil.error(exc);
} }
} }

View File

@@ -14,7 +14,7 @@ package org.dromara.hutool.socket.aio;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
/** /**
* 简易IO信息处理类<br> * 简易IO信息处理类<br>
@@ -31,6 +31,6 @@ public abstract class SimpleIoAction implements IoAction<ByteBuffer> {
@Override @Override
public void failed(final Throwable exc, final AioSession session) { public void failed(final Throwable exc, final AioSession session) {
StaticLog.error(exc); LogUtil.error(exc);
} }
} }

View File

@@ -13,7 +13,7 @@
package org.dromara.hutool.socket.nio; package org.dromara.hutool.socket.nio;
import org.dromara.hutool.core.io.IORuntimeException; import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import java.io.IOException; import java.io.IOException;
import java.nio.channels.CompletionHandler; import java.nio.channels.CompletionHandler;
@@ -33,7 +33,7 @@ public class AcceptHandler implements CompletionHandler<ServerSocketChannel, Nio
try { try {
// 获取连接到此服务器的客户端通道 // 获取连接到此服务器的客户端通道
socketChannel = serverSocketChannel.accept(); socketChannel = serverSocketChannel.accept();
StaticLog.debug("Client [{}] accepted.", socketChannel.getRemoteAddress()); LogUtil.debug("Client [{}] accepted.", socketChannel.getRemoteAddress());
} catch (final IOException e) { } catch (final IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
@@ -44,7 +44,7 @@ public class AcceptHandler implements CompletionHandler<ServerSocketChannel, Nio
@Override @Override
public void failed(final Throwable exc, final NioServer nioServer) { public void failed(final Throwable exc, final NioServer nioServer) {
StaticLog.error(exc); LogUtil.error(exc);
} }
} }

View File

@@ -4,7 +4,7 @@ import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.io.buffer.BufferUtil; import org.dromara.hutool.core.io.buffer.BufferUtil;
import org.dromara.hutool.core.lang.Console; import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.log.StaticLog; import org.dromara.hutool.log.LogUtil;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -17,7 +17,7 @@ public class AioServerTest {
@Override @Override
public void accept(final AioSession session) { public void accept(final AioSession session) {
StaticLog.debug("【客户端】:{} 连接。", session.getRemoteAddress()); LogUtil.debug("【客户端】:{} 连接。", session.getRemoteAddress());
session.write(BufferUtil.ofUtf8("=== Welcome to Hutool socket server. ===")); session.write(BufferUtil.ofUtf8("=== Welcome to Hutool socket server. ==="));
} }