sunxbiao месяцев назад: 6
Родитель
Сommit
ee441898ee
1 измененных файлов с 10 добавлено и 7 удалено
  1. 10 7
      app/command/WiwibaoProductSync.php

+ 10 - 7
app/command/WiwibaoProductSync.php

@@ -80,7 +80,7 @@ class WiwibaoProductSync extends Command
80
                         $syncedSpuIds[] = $spuId;
80
                         $syncedSpuIds[] = $spuId;
81
                     }
81
                     }
82
                 } catch (\Exception $e) {
82
                 } catch (\Exception $e) {
83
-                    Log::error("处理商品 {$product['goods_id']} 失败: " . $e->getMessage());
83
+                    $this->logError("处理商品 {$product['goods_id']} 失败: ", $e);
84
                     continue;
84
                     continue;
85
                 }
85
                 }
86
             }
86
             }
@@ -335,7 +335,7 @@ class WiwibaoProductSync extends Command
335
             return $data['spu_id'];
335
             return $data['spu_id'];
336
 
336
 
337
         } catch (\Exception $e) {
337
         } catch (\Exception $e) {
338
-            Log::error("保存商品到douhuomall失败: " . $e->getMessage());
338
+            $this->logError('保存商品到douhuomall失败: ', $e);
339
             throw $e;
339
             throw $e;
340
         }
340
         }
341
     }
341
     }
@@ -470,12 +470,15 @@ class WiwibaoProductSync extends Command
470
     {
470
     {
471
         $errorInfo = [
471
         $errorInfo = [
472
             'message' => $message,
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
         Db::name('log')->insert([
483
         Db::name('log')->insert([
481
             'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),
484
             'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),
@@ -567,7 +570,7 @@ class WiwibaoProductSync extends Command
567
             $this->insert_sku($insert_id, $sku_data);
570
             $this->insert_sku($insert_id, $sku_data);
568
             return true;
571
             return true;
569
         } catch (\Exception $e) {
572
         } catch (\Exception $e) {
570
-            Log::error($spu_id . "加入选品失败:" . $e->getMessage());
573
+            $this->logError($spu_id . "加入选品失败:", $e);
571
             return false;
574
             return false;
572
         }
575
         }
573
     }
576
     }