From 313e9339114e672eb2b281ee323f9f480f980679 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 14 六月 2023 20:37:46 +0800
Subject: [PATCH] Merge branch 'dev-hxb' into Dev-Wxr-1.8.1

---
 HDL-ON_Android/Aliyu/AliyuLogUtil.cs |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 0 deletions(-)

diff --git a/HDL-ON_Android/Aliyu/AliyuLogUtil.cs b/HDL-ON_Android/Aliyu/AliyuLogUtil.cs
new file mode 100644
index 0000000..912963b
--- /dev/null
+++ b/HDL-ON_Android/Aliyu/AliyuLogUtil.cs
@@ -0,0 +1,105 @@
+锘縰sing System;
+using Android.Content;
+using Com.Aliyun.Sls.Android.Producer;
+
+namespace HDL_ON_Android.Aliyu
+{
+    public class AliyuLogUtil
+    {
+        private static AliyuLogProducerClient exceptionProducerClient;
+        private static LogBean logBean;
+
+        private static AliyuLogProducerClient getExceptionProducerClient()
+        {
+            lock (exceptionProducerClient)
+            {
+                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();
+                }
+                return exceptionProducerClient;
+            }
+        }
+
+
+        /**
+         * 寮傚父鏃ュ織
+         *
+         * @param title    鏍囬
+         * @param content  闄勫姞鏁版嵁鍐呭
+         * @param level    鎶ヨ绛夌骇
+         */
+        public static void log(string title, string content, Level level)
+        {
+            log(title, content, level, null);
+        }
+        /**
+         * 寮傚父鏃ュ織
+         *
+         * @param title    鏍囬
+         * @param content  闄勫姞鏁版嵁鍐呭
+         * @param otherMsg 鍏朵粬闄勫姞鏁版嵁锛屾病鏈夊彲涓虹┖
+         * @param level    鎶ヨ绛夌骇
+         * @param type 寮傚父绫诲瀷
+         */
+        public static void log(string title, string content, Level level, string type)
+        {
+            log(title, content, level, null, null);
+        }
+        /**
+         * 寮傚父鏃ュ織
+         *
+         * @param title    鏍囬
+         * @param content  闄勫姞鏁版嵁鍐呭
+         * @param otherMsg 鍏朵粬闄勫姞鏁版嵁锛屾病鏈夊彲涓虹┖
+         * @param level    鎶ヨ绛夌骇
+         * @param type 寮傚父绫诲瀷
+         * @param exceptionBlock 寮傚父浠g爜鍧�
+         */
+        public static void log(string title, string content, Level level, string type, string exceptionBlock)
+        {
+            /**
+             * 娌℃湁homeId鍜寀serId  涓嶅厑璁镐笂浼�   鍙笂浼犱綇瀹呴噷闈㈢殑寮傚父  鍑忓皯浜戠鍘嬪姏
+             * 1.鐐瑰嚮椤圭洰鐨勬椂鍊欒缃�
+             * 2.鍏抽棴浣忓畢椤甸潰鐨勬椂鍊欏幓鎺�
+             */
+            if (string.IsNullOrEmpty(getLogBean.getUserId()) || string.IsNullOrEmpty(getLogBean.getHomeId()))
+            {
+                return;
+            }
+            Log log = new Log();
+            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("time", System.DateTime.UtcNow + "");
+            log.PutContent("userAgent", getLogBean.getUserAgent());
+            log.PutContent("appVersion", getLogBean.getAppVersion());
+            log.PutContent("type", type);
+            log.PutContent("exceptionBlock", exceptionBlock);
+
+            var producerClient = getExceptionProducerClient();
+            if (producerClient == null)
+            {
+                return;
+            }
+            producerClient.sendLog(log);
+
+        }
+
+        public static LogBean getLogBean
+        {
+            get {
+                if (logBean == null) {
+                    logBean = new LogBean();
+                }
+                return logBean;
+            }
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.8.0