Aucune description

Log.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Log extends Model
  5. {
  6. public static function errorLog($params,$returnValue,$interfaceName,$flag,$headers=[],$responseTime=NULL){
  7. $data['time']=date("Y-m-d H:i:s",time());
  8. $data["interfaceName"]=$interfaceName;
  9. $data['responseTime'] = $responseTime;
  10. $data["params"]=$params;
  11. $data["headers"]=$headers;
  12. $data["returnValue"]=$returnValue;
  13. if($flag){
  14. $tmpDir="success/";
  15. }else{
  16. $tmpDir="error/";
  17. }
  18. $name=date("Y-m-d",time()).".txt";
  19. error_log(json_encode($data)."\n",3,"/log/seafood_log/".$tmpDir.$name);
  20. }
  21. public static function scriptLog($params,$returnValue,$interfaceName,$flag,$headers=[],$responseTime=NULL){
  22. $data['time']=date("Y-m-d H:i:s",time());
  23. $data["interfaceName"]=$interfaceName;
  24. $data['responseTime'] = $responseTime;
  25. $data["params"]=$params;
  26. $data["headers"]=$headers;
  27. $data["returnValue"]=$returnValue;
  28. if($flag){
  29. $tmpDir="script_success/";
  30. }else{
  31. $tmpDir="script_error/";
  32. }
  33. $name=date("Y-m-d",time()).".txt";
  34. error_log(json_encode($data)."\n",3,"/log/seafood_log/".$tmpDir.$name);
  35. }
  36. }