作者 赵彬吉

update

1 <?php 1 <?php
  2 +
  3 +use App\Utils\LogUtils;
  4 +
2 define('HTTP_OPENAI_URL','http://openai.waimaoq.com/'); 5 define('HTTP_OPENAI_URL','http://openai.waimaoq.com/');
3 /** 6 /**
4 * 生成路由标识 7 * 生成路由标识
@@ -11,6 +14,22 @@ function generateRoute($string){ @@ -11,6 +14,22 @@ function generateRoute($string){
11 return trim(strtolower(preg_replace( '/[\W]+/', '-', trim($string))), '-'); 14 return trim(strtolower(preg_replace( '/[\W]+/', '-', trim($string))), '-');
12 } 15 }
13 16
  17 +/**
  18 + * 手动记录错误日志
  19 + * @param $title
  20 + * @param $params
  21 + * @param Throwable $exception
  22 + * @author zbj
  23 + * @date 2023/4/27
  24 + */
  25 +function errorLog($title, $params, Throwable $exception){
  26 + $exceptionMessage = "错误CODE:" . $exception->getCode() .
  27 + "-----错误message:" . $exception->getMessage() .
  28 + '------错误文件:' . $exception->getFile() .
  29 + '-------错误行数:' . $exception->getLine();
  30 +
  31 + LogUtils::error($title, $params, $exceptionMessage);
  32 +}
14 33
15 if(!function_exists('http_post')){ 34 if(!function_exists('http_post')){
16 /** 35 /**
@@ -62,6 +62,7 @@ class ServerConfigLogic extends BaseLogic @@ -62,6 +62,7 @@ class ServerConfigLogic extends BaseLogic
62 DB::commit(); 62 DB::commit();
63 } catch (\Exception $e) { 63 } catch (\Exception $e) {
64 DB::rollBack(); 64 DB::rollBack();
  65 + errorLog('项目运维服务配置保存失败', $param, $e);
65 $this->fail('保存失败'); 66 $this->fail('保存失败');
66 } 67 }
67 return $this->success(); 68 return $this->success();
@@ -50,6 +50,7 @@ class ProjectLogic extends BaseLogic @@ -50,6 +50,7 @@ class ProjectLogic extends BaseLogic
50 DB::commit(); 50 DB::commit();
51 }catch (\Exception $e){ 51 }catch (\Exception $e){
52 DB::rollBack(); 52 DB::rollBack();
  53 + errorLog('项目保存失败', $param, $e);
53 $this->fail('保存失败'); 54 $this->fail('保存失败');
54 } 55 }
55 return $this->success(); 56 return $this->success();
@@ -60,6 +60,7 @@ class AttrLogic extends BaseLogic @@ -60,6 +60,7 @@ class AttrLogic extends BaseLogic
60 DB::commit(); 60 DB::commit();
61 }catch (\Exception $e){ 61 }catch (\Exception $e){
62 DB::rollBack(); 62 DB::rollBack();
  63 + errorLog('产品参数保存失败', $param, $e);
63 $this->fail('保存失败'); 64 $this->fail('保存失败');
64 } 65 }
65 return $this->success(); 66 return $this->success();
@@ -33,6 +33,7 @@ class KeywordLogic extends BaseLogic @@ -33,6 +33,7 @@ class KeywordLogic extends BaseLogic
33 DB::commit(); 33 DB::commit();
34 }catch (\Exception $e){ 34 }catch (\Exception $e){
35 DB::rollBack(); 35 DB::rollBack();
  36 + errorLog('产品关键词保存失败', $param, $e);
36 $this->fail('保存失败'); 37 $this->fail('保存失败');
37 } 38 }
38 return $this->success(); 39 return $this->success();
@@ -39,6 +39,7 @@ class ProductLogic extends BaseLogic @@ -39,6 +39,7 @@ class ProductLogic extends BaseLogic
39 DB::commit(); 39 DB::commit();
40 }catch (\Exception $e){ 40 }catch (\Exception $e){
41 DB::rollBack(); 41 DB::rollBack();
  42 + errorLog('产品保存失败', $param, $e);
42 $this->fail('保存失败'); 43 $this->fail('保存失败');
43 } 44 }
44 return $this->success(); 45 return $this->success();