From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 10 七月 2020 10:52:13 +0800
Subject: [PATCH] 2020-07-10-01

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlLogLogic.cs |   51 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlLogLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlLogLogic.cs
index df93dac..5ad7ed1 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlLogLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlLogLogic.cs
@@ -43,10 +43,12 @@
         /// Log鍑哄姏
         /// </summary>
         /// <param name="ex"></param>
-        public void WriteLog(Exception ex)
+        /// <param name="appendMsg">闄勫姞娑堟伅</param>
+        public void WriteLog(Exception ex, string appendMsg = "")
         {
             //Log鍑哄姏
-            string msg = ex.Message + "\r\n";
+            string msg = appendMsg == "" ? string.Empty : appendMsg + "\r\n";
+            msg += ex.Message + "\r\n";
             msg += ex.StackTrace;
             this.WriteLog(-1, msg);
         }
@@ -60,20 +62,27 @@
         {
             lock (objLock)
             {
-                //if (div != -1)
-                //{
-                //    //鏆傛椂鍙褰曞紓甯镐俊鎭�
-                //    return;
-                //}
+                if (div != -1 && UserCenterResourse.HideOption.DetailedLog == 0)
+                {
+                    //鏆傛椂鍙褰曞紓甯镐俊鎭�
+                    return;
+                }
                 //Log鏂囦欢
-                string fileName = this.GetLogFile(div);
-                string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory, fileName);
-
-                strLog = "[" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "] " + strLog + "\r\n";
-                var sw = new System.IO.StreamWriter(fullName, true, Encoding.UTF8);
-                sw.WriteLine(strLog);
-                sw.Close();
-                sw = null;
+                System.IO.StreamWriter sw = null;
+                try
+                {
+                    string fileName = this.GetLogFile(div);
+                    string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory, fileName);
+                    strLog = "[" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "] " + strLog + "\r\n";
+                    sw = new System.IO.StreamWriter(fullName, true, Encoding.UTF8);
+                    sw.WriteLine(strLog);
+                }
+                catch { }
+                finally
+                {
+                    sw?.Close();
+                    sw = null;
+                }
             }
         }
 
@@ -85,16 +94,16 @@
         private string GetLogFile(int div)
         {
             //鍔犲瘑,鍥犱负杩欐槸鏀堕泦鏁版嵁,鏈�濂戒笉璁╁埆浜虹煡閬撹繖鏄粈涔堟渶濂�
-            string fileName = DateTime.Now.ToString("yyyyMMdd");
+            string fileName = UserCenterResourse.UserInfo.Account + "-" + DateTime.Now.ToString("yyyyMMdd");
             if (div == -1)
-            {
-                fileName += "Log";
-            }
-            else if (div == 1)
             {
                 fileName += "Error";
             }
-            fileName = UserCenterLogic.EncryptPassword("4^Olh_3f", fileName);
+            else if (div == 1)
+            {
+                fileName += "Log";
+            }
+            fileName = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, fileName);
             return fileName;
         }
         #endregion

--
Gitblit v1.8.0