From cd4189a3f0e3896a37f2307d842af6c8ee4dc0ec Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期三, 14 六月 2023 13:20:53 +0800
Subject: [PATCH] 调整日志库
---
HDL-ON_Android/Aliyu/LogBean.cs | 39 -------------------
HDL-ON_Android/Aliyu/AliyuLogUtil.cs | 31 +++++++++------
2 files changed, 19 insertions(+), 51 deletions(-)
diff --git a/HDL-ON_Android/Aliyu/AliyuLogUtil.cs b/HDL-ON_Android/Aliyu/AliyuLogUtil.cs
index 33614d0..912963b 100644
--- a/HDL-ON_Android/Aliyu/AliyuLogUtil.cs
+++ b/HDL-ON_Android/Aliyu/AliyuLogUtil.cs
@@ -7,7 +7,6 @@
public class AliyuLogUtil
{
private static AliyuLogProducerClient exceptionProducerClient;
-
private static LogBean logBean;
private static AliyuLogProducerClient getExceptionProducerClient()
@@ -16,6 +15,9 @@
{
if (exceptionProducerClient == null)
{
+ if (Shared.Application.Activity == null) {
+ return null;
+ }
exceptionProducerClient = new AliyuLogProducerClient(Shared.Application.Activity, "https://cn-hangzhou.log.aliyuncs.com", "log", "event_tracking", "LTAI5tLzDxrtsFyi3xtK3YWt", "eX31JZrRAvC2wZWPiZU0SYhlfAUMoT", null, null);
exceptionProducerClient.initProducer();
}
@@ -65,7 +67,7 @@
* 1.鐐瑰嚮椤圭洰鐨勬椂鍊欒缃�
* 2.鍏抽棴浣忓畢椤甸潰鐨勬椂鍊欏幓鎺�
*/
- if (string.IsNullOrEmpty(getLogBean().getUserId()) || string.IsNullOrEmpty(getLogBean().getHomeId()))
+ if (string.IsNullOrEmpty(getLogBean.getUserId()) || string.IsNullOrEmpty(getLogBean.getHomeId()))
{
return;
}
@@ -73,22 +75,27 @@
log.PutContent("title", title);
log.PutContent("content", content);
log.PutContent("level", level.ToString());
- log.PutContent("userId", getLogBean().getUserId());
- log.PutContent("homeId", getLogBean().getHomeId());
+ log.PutContent("userId", getLogBean.getUserId());
+ log.PutContent("homeId", getLogBean.getHomeId());
log.PutContent("time", System.DateTime.UtcNow + "");
- log.PutContent("userAgent", getLogBean().getUserAgent());
- log.PutContent("appVersion", getLogBean().getAppVersion());
+ log.PutContent("userAgent", getLogBean.getUserAgent());
+ log.PutContent("appVersion", getLogBean.getAppVersion());
log.PutContent("type", type);
log.PutContent("exceptionBlock", exceptionBlock);
- getExceptionProducerClient().sendLog(log);
+
+ var producerClient = getExceptionProducerClient();
+ if (producerClient == null)
+ {
+ return;
+ }
+ producerClient.sendLog(log);
+
}
- public static LogBean getLogBean()
+ public static LogBean getLogBean
{
- lock (logBean)
- {
- if (null == logBean)
- {
+ get {
+ if (logBean == null) {
logBean = new LogBean();
}
return logBean;
diff --git a/HDL-ON_Android/Aliyu/LogBean.cs b/HDL-ON_Android/Aliyu/LogBean.cs
index fa8025d..e1fd76c 100644
--- a/HDL-ON_Android/Aliyu/LogBean.cs
+++ b/HDL-ON_Android/Aliyu/LogBean.cs
@@ -16,14 +16,6 @@
*/
private string mac;
/**
- * 鏍囬锛屽繀椤昏濉�
- */
- private string title;
- /**
- * 鏃ュ織鏃堕棿
- */
- private string time;
- /**
* 绯荤粺锛欼OS銆丄ndroid銆乄indows銆佺綉鍏�
*/
private string userAgent;
@@ -31,7 +23,6 @@
* 杞欢鐗堟湰
*/
private string appVersion;
- private string type;
public string getUserId()
{
@@ -63,26 +54,6 @@
this.mac = mac;
}
- public string getTitle()
- {
- return title;
- }
-
- public void setTitle(string title)
- {
- this.title = title;
- }
-
- public string getTime()
- {
- return time;
- }
-
- public void setTime(string time)
- {
- this.time = time;
- }
-
public string getUserAgent()
{
return userAgent;
@@ -101,16 +72,6 @@
public void setAppVersion(string appVersion)
{
this.appVersion = appVersion;
- }
-
- public string getType()
- {
- return type;
- }
-
- public void setType(string type)
- {
- this.type = type;
}
}
}
--
Gitblit v1.8.0