瀏覽代碼

异步日志避免IO堵塞

dodo hold 2 年之前
父節點
當前提交
dfa5db64e2

+ 1 - 1
molilian.api/Controllers/public/ForwardController.cs

@@ -69,7 +69,7 @@ namespace molilian.api.Controllers
                         break;
                     }
             }
-            new LoggerLibrary("forward", "qyapi2ntfy").Info(form.Convert2Json()).Save();
+            new LoggerLibrary("forward", "qyapi2ntfy").Info(form.Convert2Json()).SaveAsync();
             return new APIResult(new { errmsg, errcode });
         }
 

+ 9 - 9
molilian.api/Controllers/public/TkController.cs

@@ -222,11 +222,11 @@ namespace molilian.api.Controllers
                 }
                 else
                 {
-                    new LoggerLibrary("api_error", "parse")
-                    .Info(s, s2)
-                    .Info($"【taobao】{account_name}", body)
-                    .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    //new LoggerLibrary("api_error", "parse")
+                    //.Info(s, s2)
+                    //.Info($"【taobao】{account_name}", body)
+                    //.Info(ex.Message, ex.StackTrace)
+                    //.SaveAsync();
                     NotifyCore.Notify(new NifyMessage
                     {
                         message = $"【转链接口异常】{account_name}\n{content}\n{content2}\n{body}\n\n{ex.Message}\n{ex.StackTrace}",
@@ -337,7 +337,7 @@ namespace molilian.api.Controllers
                     .Info(s, s2)
                     .Info($"【taobao】{account_name}", body)
                     .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    .SaveAsync();
                 NotifyCore.Notify(new NifyMessage
                 {
                     message = $"【转链接口异常】{account_name}\n{content}\n{content2}\n{body}\n\n{ex.Message}\n{ex.StackTrace}",
@@ -415,7 +415,7 @@ namespace molilian.api.Controllers
                     .Info(s, s2)
                     .Info("【jd】", body)
                     .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    .SaveAsync();
                 NotifyCore.Notify(new NifyMessage
                 {
                     message = $"【转链接口异常】\n{content}\n{content2}\n{body}\n\n{ex.Message}\n{ex.StackTrace}",
@@ -592,7 +592,7 @@ namespace molilian.api.Controllers
 
             var ids = data.Select(e => e.Id).ToArray();
             log.Info(string.Join(',', ids));
-            log.Save();
+            log.SaveAsync();
 
             return new APIResult(new
             {
@@ -636,7 +636,7 @@ namespace molilian.api.Controllers
 
             var ids = data.Select(e => e.Id).ToArray();
             log.Info(string.Join(',', ids));
-            log.Save();
+            log.SaveAsync();
 
             return new APIResult(new
             {

文件差異過大導致無法顯示
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 1 - 1
molilian.api/molilian.api.csproj

@@ -9,7 +9,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="dodohold.core" Version="1.0.1.9" />
+    <PackageReference Include="dodohold.core" Version="1.0.1.10" />
     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.0-Preview.1" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
   </ItemGroup>

+ 4 - 4
molilian.core/Core/taoke/TkLogCore.cs

@@ -209,7 +209,7 @@ namespace molilian.core
 
                 new LoggerLibrary("database_error", "parse_log")
                     .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    .SaveAsync();
 
                 NotifyCore.Notify(new NifyMessage
                 {
@@ -274,7 +274,7 @@ namespace molilian.core
                 .Info(response.rawContent, response.rawContent2)
                 .Info(response.Convert2Json())
                 .Info(ex.Message, ex.StackTrace)
-                .Save();
+                .SaveAsync();
             }
         }
 
@@ -311,7 +311,7 @@ namespace molilian.core
                 .Info(response.rawContent)
                 .Info(response.Convert2Json())
                 .Info(ex.Message, ex.StackTrace)
-                .Save();
+                .SaveAsync();
             }
         }
         public static async Task CouponLogAsync(UnionCouponDTO response, AlimamaPlus? alimamaPlus = null)
@@ -346,7 +346,7 @@ namespace molilian.core
                 .Info(response.rawContent)
                 .Info(response.Convert2Json())
                 .Info(ex.Message, ex.StackTrace)
-                .Save();
+                .SaveAsync();
             }
         }
         public static async Task ParseLogAsync(JdDataDTO response)

+ 2 - 2
molilian.core/Core/taoke/UnionCouponCore.cs

@@ -97,7 +97,7 @@ namespace molilian.core
                         .Info(ip, oaid)
                         .Info(content)
                         .Info(ex.Message, ex.StackTrace)
-                        .Save();
+                        .SaveAsync();
 
                     NotifyCore.Notify(new NifyMessage
                     {
@@ -212,7 +212,7 @@ namespace molilian.core
                         .Info(ip, oaid)
                         .Info(content)
                         .Info(ex.Message, ex.StackTrace)
-                        .Save();
+                        .SaveAsync();
                     NotifyCore.Notify(new NifyMessage
                     {
                         message = $"【转链异常JD】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",

+ 5 - 6
molilian.core/Core/taoke/UnionParseCore.cs

@@ -49,7 +49,7 @@ namespace molilian.core
                     .Info(ip, oaid)
                     .Info(content)
                     .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    .SaveAsync();
                 NotifyCore.Notify(new NifyMessage
                 {
                     message = $"【转链异常Wemeet】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
@@ -87,7 +87,7 @@ namespace molilian.core
                     .Info(ip, oaid)
                     .Info(content)
                     .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    .SaveAsync();
                 NotifyCore.Notify(new NifyMessage
                 {
                     message = $"【转链异常Pan】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
@@ -176,7 +176,6 @@ namespace molilian.core
                     });
                 }
                 result.accountId = account.id;
-                result.accountName = account.company;
                 alimama = new AlimamaPlus(account);
                 result = await alimama.UnionParse2Async(content, result);
                 result.accountName = account.company;
@@ -196,7 +195,7 @@ namespace molilian.core
                         .Info(ip, oaid)
                         .Info(content)
                         .Info(ex.Message, ex.StackTrace)
-                        .Save();
+                        .SaveAsync();
 
                     NotifyCore.Notify(new NifyMessage
                     {
@@ -276,7 +275,7 @@ namespace molilian.core
                         .Info(ip, oaid)
                         .Info(content)
                         .Info(ex.Message, ex.StackTrace)
-                        .Save();
+                        .SaveAsync();
                     NotifyCore.Notify(new NifyMessage
                     {
                         message = $"【转链异常JD】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
@@ -346,7 +345,7 @@ namespace molilian.core
                         .Info(ip, oaid)
                         .Info(content)
                         .Info(ex.Message, ex.StackTrace)
-                        .Save();
+                        .SaveAsync();
                     NotifyCore.Notify(new NifyMessage
                     {
                         message = $"【转链异常DY】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",

+ 4 - 4
molilian.core/Plus/Alimama/account.cs

@@ -59,7 +59,7 @@ namespace molilian.core
                 {
                     new LoggerLibrary("account", "error")
                         .Info(url, body)
-                        .Save();
+                        .SaveAsync();
                     throw new Exception(body);
                 }
 
@@ -135,7 +135,7 @@ namespace molilian.core
                     {
                         new LoggerLibrary("account", "error")
                             .Info(url, body)
-                            .Save();
+                            .SaveAsync();
                         return (false, body);
                     }
                     //{"success":false,"msgInfo":"用户淘宝未登录","msgCode":"USER_TB_NOT_LOGIN"}
@@ -167,7 +167,7 @@ namespace molilian.core
                     {
                         new LoggerLibrary("account", "error")
                             .Info(url, body)
-                            .Save();
+                            .SaveAsync();
                         return (false, body);
                     }
                 }
@@ -225,7 +225,7 @@ namespace molilian.core
             {
                 new LoggerLibrary("account", "error")
                     .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    .SaveAsync();
 
                 string message = $"【cookie续期异常】{_accountName}\n\n{ex.Message}\n{ex.StackTrace}";
                 NotifyCore.Notify(new NifyMessage

+ 1 - 1
molilian.core/Plus/Alimama/bills.cs

@@ -46,7 +46,7 @@ namespace molilian.core
                 {
                     new LoggerLibrary("api_error", "fail")
                         .Info(response.ResponseException.Message, response.ResponseException.StackTrace)
-                        .Save();
+                        .SaveAsync();
                     throw response.ResponseException;
                 }
                 var body = response.Body();

+ 5 - 5
molilian.core/Plus/Alimama/crawler.cs

@@ -214,7 +214,7 @@ ON DUPLICATE KEY UPDATE
                 {
                     new LoggerLibrary("report", "error")
                         .Info(url, body)
-                        .Save();
+                        .SaveAsync();
                     throw new Exception(body);
                 }
 
@@ -326,7 +326,7 @@ ON DUPLICATE KEY UPDATE
                 {
                     new LoggerLibrary("report", "error")
                         .Info(url, body)
-                        .Save();
+                        .SaveAsync();
                     throw new Exception(body);
                 }
 
@@ -412,7 +412,7 @@ ON DUPLICATE KEY UPDATE
             {
                 new LoggerLibrary("report", "error")
                     .Info(url, body)
-                    .Save();
+                    .SaveAsync();
                 throw new Exception(body);
             }
 
@@ -515,11 +515,11 @@ ON DUPLICATE KEY UPDATE
                 {
                     new LoggerLibrary("violationu", "warning_error")
                         .Info(url, body)
-                        .Save();
+                        .SaveAsync();
                     throw new Exception(body);
                 }
                 if (totalCount == 0) return;
-                new LoggerLibrary("violationu", "warning").Info(url, body).Save();
+                new LoggerLibrary("violationu", "warning").Info(url, body).SaveAsync();
 
                 var list = root.ElementRead("data").ElementRead("result").EnumerateArray();
                 foreach (var data in list)

+ 3 - 3
molilian.core/Plus/Alimama/orders.cs

@@ -175,7 +175,7 @@ SET tr.order_ord_amt_14 = sub.order_ord_amt, tr.order_ord_tfee_14 = sub.order_or
                 {
                     new LoggerLibrary("api_error", "fail")
                         .Info(response.ResponseException.Message, response.ResponseException.StackTrace)
-                        .Save();
+                        .SaveAsync();
                     throw response.ResponseException;
                 }
                 var body = response.Body();
@@ -340,11 +340,11 @@ SET tr.order_ord_amt_14 = sub.order_ord_amt, tr.order_ord_tfee_14 = sub.order_or
                 {
                     new LoggerLibrary("violationu", "warning_error")
                         .Info(url, body)
-                        .Save();
+                        .SaveAsync();
                     throw new Exception(body);
                 }
                 if (totalCount == 0) return;
-                new LoggerLibrary("violationu", "warning").Info(url, body).Save();
+                new LoggerLibrary("violationu", "warning").Info(url, body).SaveAsync();
 
                 var list = root.ElementRead("data").ElementRead("result").EnumerateArray();
                 foreach (var data in list)

+ 7 - 7
molilian.core/Plus/Alimama/parse_2.cs

@@ -154,7 +154,7 @@ namespace molilian.core
 #if DEBUG
                 client.Proxy = null;
 #else
-                client.Timeout = TimeSpan.FromMilliseconds(5000);
+                client.Timeout = TimeSpan.FromMilliseconds(3000);
 #endif
                 var response = client.Request(url);
 
@@ -287,7 +287,7 @@ namespace molilian.core
 #endif
             if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
 
-            client.Timeout = TimeSpan.FromMilliseconds(2000);
+            client.Timeout = TimeSpan.FromMilliseconds(1000);
             var response = client.Request(url);
 
             var body = string.Empty;
@@ -306,7 +306,7 @@ namespace molilian.core
                     {
                         new LoggerLibrary("api_error", "fail")
                             .Info(response.ResponseException.Message, response.ResponseException.StackTrace)
-                            .Save();
+                            .SaveAsync();
                         throw response.ResponseException;
                     }
 
@@ -391,7 +391,7 @@ namespace molilian.core
                             new LoggerLibrary("api_error", "fail")
                                 .Info(message, content)
                                 .Info(headers, body)
-                                .Save();
+                                .SaveAsync();
                             break;
                     }
                 }
@@ -462,7 +462,7 @@ namespace molilian.core
                         .AddHeaders("Cookie", _cookies);
             client.Proxy = _proxy;
             if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
-            client.Timeout = TimeSpan.FromMilliseconds(2000);
+            client.Timeout = TimeSpan.FromMilliseconds(1000);
 #if DEBUG
             client.Proxy = null;
             client.Timeout = TimeSpan.FromMilliseconds(10000);
@@ -485,7 +485,7 @@ namespace molilian.core
                     {
                         new LoggerLibrary("api_error", "fail")
                             .Info(response.ResponseException.Message, response.ResponseException.StackTrace)
-                            .Save();
+                            .SaveAsync();
                         throw response.ResponseException;
                     }
                     return result;
@@ -573,7 +573,7 @@ namespace molilian.core
                             new LoggerLibrary("api_error", "fail")
                                 .Info(message, content)
                                 .Info(headers, body)
-                                .Save();
+                                .SaveAsync();
                             break;
                     }
                 }

+ 4 - 4
molilian.core/Plus/DataokePlus.cs

@@ -84,7 +84,7 @@ namespace molilian.core
 
             var log = new LoggerLibrary("dataoke", "promotion-union-convert").Info(unionId, materialId);
             string body = app.Get(api, version, apiParameters);
-            log.Info(body).Save();
+            log.Info(body).SaveAsync();
             //var root = body.Convert2JsonElement();
             return body;
         }
@@ -104,7 +104,7 @@ namespace molilian.core
 
                 var log = new LoggerLibrary("dataoke", "details").Info(string.Join(',', skuIds));
                 body = app.Get(api, version, apiParameters);
-                log.Info(body).Save();
+                log.Info(body).SaveAsync();
 
 
                 var root = body.Convert2JsonElement();
@@ -120,7 +120,7 @@ namespace molilian.core
                 new LoggerLibrary("dtk_error", "fail")
                     .Info(string.Join(',', skuIds), body)
                     .Info(ex.Message, ex.StackTrace)
-                    .Save();
+                    .SaveAsync();
 
                 NotifyCore.Notify(new NifyMessage
                 {
@@ -155,7 +155,7 @@ namespace molilian.core
 
                 var log = new LoggerLibrary("dataoke", "parseUrl").Info(url);
                 string body = app.Get(api, version, apiParameters);
-                log.Info(body).Save();
+                log.Info(body).SaveAsync();
 
                 var root = body.Convert2JsonElement();
                 int code = root.Read<int>("code", -1);

+ 3 - 3
molilian.core/Plus/DyUnion/base.cs

@@ -121,13 +121,13 @@ namespace molilian.core
 
         //        if (!result.Successed)
         //        {
-        //            new LoggerLibrary("pangolin", "webcast_room_reflow").Info($"{room_id}").Info(result.ResponseException.Message, result.ResponseException.StackTrace).Save();
+        //            new LoggerLibrary("pangolin", "webcast_room_reflow").Info($"{room_id}").Info(result.ResponseException.Message, result.ResponseException.StackTrace).SaveAsync();
         //            return null;
         //        }
         //    }
         //    catch (Exception ex)
         //    {
-        //        new LoggerLibrary("pangolin", "webcast_room_reflow").Info($"{room_id}").Info(ex.Message, ex.StackTrace).Save();
+        //        new LoggerLibrary("pangolin", "webcast_room_reflow").Info($"{room_id}").Info(ex.Message, ex.StackTrace).SaveAsync();
         //        return null;
         //    }
 
@@ -158,7 +158,7 @@ namespace molilian.core
             client.Post(postData);
             var response = await client.RequestAsync(url);
             var body = response.Body();
-            log.Info(body).Save();
+            log.Info(body).SaveAsync();
 
             //var root = body.Convert2JsonElement();
             return body;

+ 2 - 2
molilian.core/Plus/JDUnion/base.cs

@@ -78,7 +78,7 @@ namespace molilian.core
             var client = new WebClientUtility();
             var response = client.Request(url);
             var body = response.Body();
-            log.Info(body).Save();
+            log.Info(body).SaveAsync();
 
             //var root = body.Convert2JsonElement();
             return body;
@@ -104,7 +104,7 @@ namespace molilian.core
             var client = new WebClientUtility();
             var response = await client.RequestAsync(url);
             var body = response.Body();
-            log.Info(body).Save();
+            log.Info(body).SaveAsync();
 
             return body;
         }

+ 2 - 2
molilian.core/Plus/JDUnion/goods.cs

@@ -60,7 +60,7 @@ namespace molilian.core
                     return url;
                 }
             }
-            new LoggerLibrary("JdUnion", "promotion_get_error").Info(body).Save();
+            new LoggerLibrary("JdUnion", "promotion_get_error").Info(body).SaveAsync();
             return null;
         }
 
@@ -93,7 +93,7 @@ namespace molilian.core
                     return url;
                 }
             }
-            new LoggerLibrary("JdUnion", "promotion_get_error").Info(body).Save();
+            new LoggerLibrary("JdUnion", "promotion_get_error").Info(body).SaveAsync();
             return null;
         }
 

+ 1 - 1
molilian.core/Plus/UploadFile/ImageHostingPlus.cs

@@ -87,7 +87,7 @@ namespace molilian.core
             result.success = root.Read<bool>("success", false);
             if (result.success)
             {
-                LoggerLibrary log = new LoggerLibrary("ImageHosting", "meituan").Info(responseBody).Save();
+                new LoggerLibrary("ImageHosting", "meituan").Info(responseBody).SaveAsync();
             }
 
             result.code = root.Read<int>("code", 0);

+ 1 - 1
molilian.core/molilian.core.csproj

@@ -13,7 +13,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="dodohold.core" Version="1.0.1.9" />
+    <PackageReference Include="dodohold.core" Version="1.0.1.10" />
     <PackageReference Include="FakeUserAgent" Version="1.0.2" />
     <PackageReference Include="IP2Region.Net" Version="2.0.2" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />

部分文件因文件數量過多而無法顯示