中文日志改为英文

This commit is contained in:
aoshiguchen
2023-09-19 12:56:42 +08:00
parent 67c362b423
commit 5578874df7
26 changed files with 84 additions and 85 deletions
@@ -46,7 +46,7 @@ public class ProxyServer {
logger.setLevel(level);
}
} catch (Exception e) {
log.error("日志级别设置失败", e);
log.error("logger level set failed", e);
}
}
}
@@ -57,7 +57,7 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
dbTypeEnum = DbTypeEnum.of(dbConfig.getType());
Assert.notNull(dbTypeEnum, "neutrino.data.db.type取值异常!");
log.info("{}数据库初始化...", dbConfig.getType());
log.info("{} database init...", dbConfig.getType());
initDBStructure();
initDBData();
}
@@ -82,7 +82,7 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
}
sql += "\r\n" + line.trim();
if (sql.endsWith(";")) {
log.debug("初始化数据库表 sql:{}", sql);
log.debug("init database table sql:{}", sql);
Db.update(sql);
sql = "";
}
@@ -116,7 +116,7 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
}
sql += "\r\n" + line.trim();
if (sql.endsWith(";")) {
log.debug("初始化数据[table={}] sql:{}", tableName, sql);
log.debug("init database data[table={}] sql:{}", tableName, sql);
Db.update(sql);
sql = "";
}
@@ -38,7 +38,7 @@ public class ProxyConfiguration implements LifecycleBean {
@Override
public void start() throws Throwable {
List<ProxyMessageHandler> list = Solon.context().getBeansOfType(ProxyMessageHandler.class);
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("消息调度器", list,
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("MessageDispatcher", list,
proxyMessage -> ProxyDataTypeEnum.of((int)proxyMessage.getType()) == null ?
null : ProxyDataTypeEnum.of((int)proxyMessage.getType()).getName());
@@ -74,7 +74,7 @@ public class BaseAuthInterceptor implements RouterInterceptor {
}
if (result instanceof Throwable) {
log.error("全局异常", (Throwable) result);
log.error("global error", (Throwable) result);
if (result instanceof ServiceException) {
ServiceException exception = (ServiceException) result;
@@ -23,7 +23,7 @@ public class GlobalExceptionFilter implements Filter {
try {
chain.doFilter(ctx);
} catch (Throwable e) {
log.error("全局异常", e);
log.error("global error", e);
if (e instanceof ServiceException) {
ServiceException serviceException = (ServiceException) e;
@@ -31,7 +31,7 @@ public class VisitLogInterceptor implements RouterInterceptor {
} finally {
Date now = new Date();
long elapsedTime = now.getTime() - startTime.getTime();
log.debug("\n-----------------------------------------------------------------接口请求日志\n{} url:{} 执行耗时:{}\n请求体参数:{}\n响应结果:{}\n客户端IP:{}\n",
log.debug("\n-----------------------------------------------------------------interface request log\n{} url:{} elapsed time:{}\nrequest:{}\nresponse:{}\nclient ip:{}\n",
ctx.method(), ctx.path(), getElapsedTimeStr(elapsedTime),
JSONObject.toJSONString(ctx.paramMap()),
JSONObject.toJSONString(JSONObject.toJSONString(ctx.result)),
@@ -47,11 +47,11 @@ public class VisitLogInterceptor implements RouterInterceptor {
*/
private static String getElapsedTimeStr(long elapsedTime) {
if (elapsedTime < 1000) {
return String.format("%s毫秒", elapsedTime);
return String.format("%sms", elapsedTime);
} else if (elapsedTime < 60000) {
return String.format("%.2f", (elapsedTime * 1.0) / 1000);
return String.format("%.2fs", (elapsedTime * 1.0) / 1000);
}
return String.format("%.2f分钟", (elapsedTime * 1.0) / 1000 / 60);
return String.format("%.2fm", (elapsedTime * 1.0) / 1000 / 60);
}
}
@@ -70,37 +70,37 @@ public class DataCleanJob implements IJobHandler {
{
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getJobLogKeepDays());
log.info("清理调度管理日志 date:{}", sdf.format(date));
log.info("clean job log date:{}", sdf.format(date));
jobLogMapper.clean(date);
}
{
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getUserLoginRecordKeepDays());
log.info("清理用户登录日志 date:{}", sdf.format(date));
log.info("clean user login record date:{}", sdf.format(date));
userLoginRecordMapper.clean(date);
}
{
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getClientConnectRecordKeepDays());
log.info("清理客户端连接日志 date:{}", sdf.format(date));
log.info("clean client connect record date:{}", sdf.format(date));
clientConnectRecordMapper.clean(date);
}
{
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getFlowMinuteReportKeepDays());
log.info("清理流通统计分钟报表日志 date:{}", sdf.format(date));
log.info("clean flow report minute record date:{}", sdf.format(date));
flowReportMinuteMapper.clean(date);
}
{
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getFlowHourReportKeepDays());
log.info("清理流通统计小时报表日志 date:{}", sdf.format(date));
log.info("clean flow report hour record date:{}", sdf.format(date));
flowReportHourMapper.clean(date);
}
{
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getFlowDayReportKeepDays());
log.info("清理流通统计日报表日志 date:{}", sdf.format(date));
log.info("clean flow report day record date:{}", sdf.format(date));
flowReportDayMapper.clean(date);
}
}
@@ -136,7 +136,7 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
switch (event.state()) {
case READER_IDLE:
// 读超时,断开连接
log.debug("读超时");
log.debug("Read timeout");
ctx.channel().close();
break;
case WRITER_IDLE:
@@ -59,9 +59,9 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
});
try {
bootstrap.bind(proxyConfig.getTunnel().getPort()).sync();
log.info("代理服务启动,端口{}", proxyConfig.getTunnel().getPort());
log.info("proxy server startedport{}", proxyConfig.getTunnel().getPort());
} catch (Exception e) {
log.error("代理服务异常", e);
log.error("proxy server error", e);
}
}
@@ -80,9 +80,9 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
});
try {
bootstrap.bind(proxyConfig.getTunnel().getSslPort()).sync();
log.info("代理服务启动,SSL端口 {}", proxyConfig.getTunnel().getSslPort());
log.info("proxy server startedSSL port {}", proxyConfig.getTunnel().getSslPort());
} catch (Exception e) {
log.error("代理服务异常", e);
log.error("proxy server error", e);
}
}
@@ -105,7 +105,7 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
return new SslHandler(sslEngine);
} catch (Exception e) {
log.error("创建SSL处理器失败", e);
log.error("create SSL handler error", e);
e.printStackTrace();
}
return null;
@@ -50,7 +50,7 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
}
});
bootstrap.bind("0.0.0.0", proxyConfig.getServer().getTcp().getHttpProxyPort()).sync();
log.info("Http代理服务启动成功port:{}", proxyConfig.getServer().getTcp().getHttpProxyPort());
log.info("Http proxy server start successport:{}", proxyConfig.getServer().getTcp().getHttpProxyPort());
} catch (Exception e) {
log.error("http proxy start err!", e);
}
@@ -59,7 +59,7 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
}
});
bootstrap.bind("0.0.0.0", proxyConfig.getServer().getTcp().getHttpsProxyPort()).sync();
log.info("Https代理服务启动成功port:{}", proxyConfig.getServer().getTcp().getHttpsProxyPort());
log.info("Https proxy server startedport:{}", proxyConfig.getServer().getTcp().getHttpsProxyPort());
} catch (Exception e) {
log.error("https proxy start err!", e);
}
@@ -84,7 +84,7 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
return new SslHandler(sslEngine);
} catch (Exception e) {
log.error("创建SSL处理器失败", e);
log.error("create SSL handler failed", e);
e.printStackTrace();
}
return null;
@@ -89,7 +89,7 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
}
if (StrUtil.isEmpty(licenseKey)) {
log.warn("[客户端连接] license不能为空 info:{} ", info);
log.warn("[client connection] license cannot empty info:{} ", info);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不能为空!", licenseKey));
ctx.channel().close();
clientConnectRecordService.add(new ClientConnectRecordDO()
@@ -97,14 +97,14 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
.setType(ClientConnectTypeEnum.CONNECT.getType())
.setMsg(licenseKey)
.setCode(SuccessCodeEnum.FAIL.getCode())
.setErr("license不能为空!")
.setErr("license cannot empty!")
.setCreateTime(now)
);
return;
}
LicenseDO licenseDO = licenseService.findByKey(licenseKey);
if (null == licenseDO) {
log.warn("[客户端连接] license不存在 info:{} ", info);
log.warn("[client connection] license notfound info:{} ", info);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不存在!", licenseKey));
ctx.channel().close();
clientConnectRecordService.add(new ClientConnectRecordDO()
@@ -112,14 +112,14 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
.setType(ClientConnectTypeEnum.CONNECT.getType())
.setMsg(licenseKey)
.setCode(SuccessCodeEnum.FAIL.getCode())
.setErr("license不存在!")
.setErr("license notfound!")
.setCreateTime(now)
);
return;
}
if (EnableStatusEnum.DISABLE.getStatus().equals(licenseDO.getEnable())) {
log.warn("[客户端连接] 当前license已被禁用 info:{} ", info);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license已被禁用!", licenseKey));
log.warn("[client connection] the license disabled info:{} ", info);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "the license disabled!", licenseKey));
ctx.channel().close();
clientConnectRecordService.add(new ClientConnectRecordDO()
.setIp(ip)
@@ -127,14 +127,14 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
.setType(ClientConnectTypeEnum.CONNECT.getType())
.setMsg(licenseKey)
.setCode(SuccessCodeEnum.FAIL.getCode())
.setErr("当前license已被禁用!")
.setErr("the license disabled!")
.setCreateTime(now));
return;
}
UserDO userDO = userService.findById(licenseDO.getUserId());
if (null == userDO || EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) {
log.warn("[客户端连接] 当前license无效 info:{} ", info);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license无效!", licenseKey));
log.warn("[client connection] the license invalid info:{} ", info);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "the license invalid!", licenseKey));
ctx.channel().close();
clientConnectRecordService.add(new ClientConnectRecordDO()
.setIp(ip)
@@ -142,7 +142,7 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
.setType(ClientConnectTypeEnum.CONNECT.getType())
.setMsg(licenseKey)
.setCode(SuccessCodeEnum.FAIL.getCode())
.setErr("当前license无效!")
.setErr("the license invalid!")
.setCreateTime(now));
return;
}
@@ -150,8 +150,8 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
if (null != cmdChannel) {
String _clientId = ProxyUtil.getClientIdByLicenseId(licenseDO.getId());
if (!clientId.equals(_clientId)) {
log.warn("[客户端连接] 当前license已被另一节点使用 info:{} _clientId:{}", info, _clientId);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license已被另一节点使用!", licenseKey));
log.warn("[client connection] the license on another no used info:{} _clientId:{}", info, _clientId);
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "the license on another no used!", licenseKey));
ctx.channel().close();
clientConnectRecordService.add(new ClientConnectRecordDO()
.setIp(ip)
@@ -159,13 +159,13 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
.setType(ClientConnectTypeEnum.CONNECT.getType())
.setMsg(licenseKey)
.setCode(SuccessCodeEnum.FAIL.getCode())
.setErr("当前license已被另一节点使用!")
.setErr("the license on another no used!")
.setCreateTime(now));
return;
}
}
// 发送认证成功消息
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.SUCCESS.getCode(), "认证成功!", licenseKey));
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.SUCCESS.getCode(), "auth success!", licenseKey));
clientConnectRecordService.add(new ClientConnectRecordDO()
.setIp(ip)
@@ -178,7 +178,7 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
// 设置当前licenseId对应的客户端ID
ProxyUtil.setLicenseIdToClientIdMap(licenseDO.getId(), clientId);
log.warn("[客户端连接] 认证成功 info:{} ", info);
log.warn("[client connection] auth success info:{} ", info);
// 更新license在线状态
licenseMapper.updateOnlineStatus(licenseDO.getId(), OnlineStatusEnum.ONLINE.getStatus(), now);
@@ -60,11 +60,11 @@ public class JobLogService implements IJobCallback {
Integer code = 0;
String msg = "";
if (null == throwable) {
msg = "执行成功";
log.debug("job[id={},name={}]执行完毕", jobInfo.getId(), jobInfo.getName());
msg = "execute success";
log.debug("job[id={},name={}]execute success", jobInfo.getId(), jobInfo.getName());
} else {
log.error("job[id={},name={}]执行异常", jobInfo.getId(), jobInfo.getName(), throwable);
msg = "执行异常:\r\n" + ExceptionUtils.getStackTrace(throwable);
log.error("job[id={},name={}]execute error", jobInfo.getId(), jobInfo.getName(), throwable);
msg = "execute error:\r\n" + ExceptionUtils.getStackTrace(throwable);
code = -1;
}
jobLogMapper.insert(new JobLogDO()
@@ -53,7 +53,7 @@ public class ProxyMutualService {
Date now = new Date();
portMappingMapper.updateOnlineStatus(attachInfo.getLicenseId(), serverPort, OnlineStatusEnum.ONLINE.getStatus(), now);
licenseMapper.updateOnlineStatus(attachInfo.getLicenseId(), OnlineStatusEnum.ONLINE.getStatus(), now);
log.info("绑定服务端端口 licenseId:{},ip:{},serverPort:{}", attachInfo.getLicenseId(), attachInfo.getIp(), serverPort);
log.info("bind server port licenseId:{},ip:{},serverPort:{}", attachInfo.getLicenseId(), attachInfo.getIp(), serverPort);
}
/**
@@ -64,7 +64,7 @@ public class ProxyMutualService {
Date now = new Date();
portMappingMapper.updateOnlineStatus(attachInfo.getLicenseId(), OnlineStatusEnum.OFFLINE.getStatus(), now);
licenseMapper.updateOnlineStatus(attachInfo.getLicenseId(), OnlineStatusEnum.OFFLINE.getStatus(), now);
log.info("客户端下线 licenseId:{},ip:{}", attachInfo.getLicenseId(), attachInfo.getIp());
log.info("client offline licenseId:{},ip:{}", attachInfo.getLicenseId(), attachInfo.getIp());
}
}
@@ -232,10 +232,10 @@ public class VisitorChannelService {
NetworkProtocolEnum networkProtocolEnum = NetworkProtocolEnum.of(portMapping.getProtocal());
if (networkProtocolEnum == NetworkProtocolEnum.UDP) {
udpServerBootstrap.bind(portMapping.getServerPort()).get();
log.info("绑定UDP用户端口 {}", portMapping.getServerPort());
log.info("bind UDP user port {}", portMapping.getServerPort());
} else {
tcpServerBootstrap.bind(portMapping.getServerPort()).get();
log.info("绑定TCP用户端口 {}", portMapping.getServerPort());
log.info("bind TCP user port {}", portMapping.getServerPort());
}
} catch (Exception ex) {
// BindException表示该端口已经绑定过