作者 zhl

add log

... ... @@ -20,6 +20,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class CopyProjectJob implements ShouldQueue
... ... @@ -52,6 +53,7 @@ class CopyProjectJob implements ShouldQueue
$projectModel = new Project();
DB::beginTransaction();
try {
$this->output('CopyProjectJob start, project_id: ' . $this->param['project_id']);
//复制初始项目
$data = $projectModel::where('id', $this->param['project_id'])->first();
$data = $data->getAttributes();
... ... @@ -128,6 +130,7 @@ class CopyProjectJob implements ShouldQueue
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->output('CopyProjectJob error, project_id: ' . $this->param['project_id'] . ', error: ' . $e->getMessage());
$this->fail('error');
}
if($type != 0){
... ... @@ -135,6 +138,7 @@ class CopyProjectJob implements ShouldQueue
}
//修改项目状态
$projectModel->edit(['delete_status'=>0],['id'=>$project_id]);
$this->output('CopyProjectJob end, old project_id: ' . $this->param['project_id'] . ', new project_id: ' . $project_id);
return true;
}
... ... @@ -184,4 +188,17 @@ class CopyProjectJob implements ShouldQueue
}
return true;
}
/**
* @param $message
* @return bool
*/
public function output($message)
{
$date = date('Y-m-d H:i:s');
$output = $date . ', ' . $message . PHP_EOL;
echo $output;
Log::info($output);
return true;
}
}
... ...