From b71d00aa66f5990a6466037aeccc31921a5978dc Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 20 Feb 2023 20:39:13 +0800 Subject: [PATCH] log replace --- .../mogo/telematic/client/NettyTcpClient.java | 32 +++++++++---------- .../discovery/AbstractDiscoveryTask.java | 10 +++--- .../discovery/DiscoveryDriverTask.java | 24 +++++++------- .../telematic/discovery/bean/NetInfo.java | 11 ++++--- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java index 48ccfab..8e9d469 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java @@ -6,8 +6,8 @@ import static com.mogo.telematic.MogoLengthFrameDecoder.MAX_FRAME_LENGTH; import static com.mogo.telematic.MogoProtocolMsg.IDENTITY_REGIST; import android.text.TextUtils; -import android.util.Log; +import com.elegant.log.simplelog.Logger; import com.mogo.telematic.MogoLengthFrameDecoder; import com.mogo.telematic.MogoMessageEncoder; import com.mogo.telematic.MogoProtocolMsg; @@ -122,7 +122,7 @@ public class NettyTcpClient { public void connect() { if (isConnecting) { - Log.d(TAG, "正在连接中,connect return"); + Logger.d(TAG, "正在连接中,connect return"); return; } Thread clientThread = new Thread("client-Netty") { @@ -160,12 +160,12 @@ public class NettyTcpClient { } }); } catch (Exception e) { - Log.w(TAG, "初始化出错的原因为:" + e.getMessage()); + Logger.w(TAG, "初始化出错的原因为:" + e.getMessage()); } } private void connectServer() { - Log.d(TAG, "connectServer fun is called."); + Logger.d(TAG, "connectServer fun is called."); synchronized (NettyTcpClient.this) { if (!isConnected) { isConnecting = true; @@ -175,18 +175,18 @@ public class NettyTcpClient { initBootstrap(); doConnect(); } else { - Log.w(TAG, "socket正在连接中,无需重连"); + Logger.w(TAG, "socket正在连接中,无需重连"); } } } private void doConnect() { if (channel != null && channel.isOpen() && channel.isActive()) { - Log.w(TAG, "Channel is active, no need to call start."); + Logger.w(TAG, "Channel is active, no need to call start."); return; } if (!canReconnect) { - Log.d(TAG, "重连已被关闭则直接return."); + Logger.d(TAG, "重连已被关闭则直接return."); return; } ChannelFuture channelFuture; @@ -206,12 +206,12 @@ public class NettyTcpClient { // future.channel().eventLoop().shutdownGracefully(); // } channel = null; - Log.e(TAG, "连接已经结束!"); + Logger.e(TAG, "连接已经结束!"); }); - Log.d(TAG, "连接获取channel已完成!"); + Logger.d(TAG, "连接获取channel已完成!"); } } catch (Exception e) { - Log.e(TAG, "连接Server ip:" + host + ",port:" + tcp_port + ",失败信息:" + e.getMessage()); + Logger.e(TAG, "连接Server ip:" + host + ",port:" + tcp_port + ",失败信息:" + e.getMessage()); isConnected = false; } } @@ -239,7 +239,7 @@ public class NettyTcpClient { byte[] signByteArr = mSign.getBytes(); MogoProtocolMsg msg = new MogoProtocolMsg(IDENTITY_REGIST, signByteArr.length, signByteArr); sendMsgToServer(msg, isSuccess -> { - Log.d(TAG, "身份注册成功:" + isSuccess); + Logger.d(TAG, "身份注册成功:" + isSuccess); }); } } @@ -248,21 +248,21 @@ public class NettyTcpClient { private ChannelFutureListener mFutureListener = channelFuture -> { if (channelFuture.isDone()) { if (channelFuture.isSuccess()) { - Log.d(TAG, "连接成功"); + Logger.d(TAG, "连接成功"); reconnectNum = MAX_CONNECT_TIMES; isConnected = true; } else { if (channelFuture.isCancelled()) { - Log.w(TAG, "Connection attempt cancelled by user."); + Logger.w(TAG, "Connection attempt cancelled by user."); } else { - Log.e(TAG, "连接失败原因为:" + channelFuture.cause().getMessage()); + Logger.e(TAG, "连接失败原因为:" + channelFuture.cause().getMessage()); } isConnected = false; channelFuture.channel().pipeline().fireChannelInactive(); } isConnecting = false; } else { - Log.w(TAG, "Connection isn't done."); + Logger.w(TAG, "Connection isn't done."); isConnected = false; } synchronized (NettyTcpClient.this) { @@ -271,7 +271,7 @@ public class NettyTcpClient { }; public void disconnect() { - Log.e(TAG, "disconnect"); + Logger.e(TAG, "disconnect"); isNeedReconnect = false; group.shutdownGracefully(); group = null; diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/discovery/AbstractDiscoveryTask.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/discovery/AbstractDiscoveryTask.java index ad8f491..9fe38c0 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/discovery/AbstractDiscoveryTask.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/discovery/AbstractDiscoveryTask.java @@ -1,8 +1,8 @@ package com.mogo.telematic.discovery; import android.os.AsyncTask; -import android.util.Log; +import com.elegant.log.simplelog.Logger; import com.mogo.telematic.discovery.bean.HostBean; import com.mogo.telematic.discovery.bean.NetInfo; @@ -38,7 +38,7 @@ public abstract class AbstractDiscoveryTask extends AsyncTask cannot find cidr, using default /24"); + Logger.i(TAG, e.getMessage() + " -> cannot find cidr, using default /24"); } } } @@ -107,7 +108,7 @@ public class NetInfo { } } } catch (Exception e) { - Log.e(TAG, "Can't use native command: " + e.getMessage()); + Logger.e(TAG, "Can't use native command: " + e.getMessage()); return null; } return null;