Kaynağa Gözat

完善日志

sunxbiao 6 ay önce
ebeveyn
işleme
ee441898ee
1 değiştirilmiş dosya ile 10 ekleme ve 7 silme
  1. 10 7
      app/command/WiwibaoProductSync.php

+ 10 - 7
app/command/WiwibaoProductSync.php

@@ -80,7 +80,7 @@ class WiwibaoProductSync extends Command
80 80
                         $syncedSpuIds[] = $spuId;
81 81
                     }
82 82
                 } catch (\Exception $e) {
83
-                    Log::error("处理商品 {$product['goods_id']} 失败: " . $e->getMessage());
83
+                    $this->logError("处理商品 {$product['goods_id']} 失败: ", $e);
84 84
                     continue;
85 85
                 }
86 86
             }
@@ -335,7 +335,7 @@ class WiwibaoProductSync extends Command
335 335
             return $data['spu_id'];
336 336
 
337 337
         } catch (\Exception $e) {
338
-            Log::error("保存商品到douhuomall失败: " . $e->getMessage());
338
+            $this->logError('保存商品到douhuomall失败: ', $e);
339 339
             throw $e;
340 340
         }
341 341
     }
@@ -470,12 +470,15 @@ class WiwibaoProductSync extends Command
470 470
     {
471 471
         $errorInfo = [
472 472
             'message' => $message,
473
-            'file' => $e->getFile(),
474
-            'line' => $e->getLine(),
475
-            'error' => $e->getMessage()
473
+            'error_message' => $e->getMessage(),
474
+            'error_file' => $e->getFile(),
475
+            'error_line' => $e->getLine(),
476
+            'error_code' => $e->getCode(),
477
+            'exception_class' => get_class($e),
478
+            'trace' => $e->getTraceAsString()
476 479
         ];
477 480
 
478
-        Log::error('商品同步错误' . json_encode($errorInfo, JSON_UNESCAPED_UNICODE));
481
+        Log::error($message . json_encode($errorInfo, JSON_UNESCAPED_UNICODE));
479 482
 
480 483
         Db::name('log')->insert([
481 484
             'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),
@@ -567,7 +570,7 @@ class WiwibaoProductSync extends Command
567 570
             $this->insert_sku($insert_id, $sku_data);
568 571
             return true;
569 572
         } catch (\Exception $e) {
570
-            Log::error($spu_id . "加入选品失败:" . $e->getMessage());
573
+            $this->logError($spu_id . "加入选品失败:", $e);
571 574
             return false;
572 575
         }
573 576
     }