public function onWorkerStop(SwooleServer $server, $worker_id)
    {
        //不能在这里处理 coroutine ，所以不能使用 Yii::$app
        $contexts = Yii::$context->getContextData();
        foreach ($contexts as $context){
            /** @var Application $application */
            $application = $context[Context::COROUTINE_APP] ?? null;
            if(empty($application)){
                continue;
            }
            $targets = $application->getLog()->targets;
            foreach ($targets as $target) {
                $target->export();
            }
        }

    }
public function onWorkerStop(SwooleServer $server, $worker_id)
    {
        //不能在这里处理 coroutine ，所以不能使用 Yii::$app
        $contexts = Yii::$context->getContextData();
        foreach ($contexts as $context){
            /** @var Application $application */
            $application = $context[Context::COROUTINE_APP] ?? null;
            if(empty($application)){
                continue;
            }
            $targets = $application->getLog()->targets;
            foreach ($targets as $target) {
                $target->export();
            }
        }

    }
public function onWorkerStop ( SwooleServer $ server , $ worker_id ) { //不能在这里处理 coroutine ，所以不能使用 Yii::$app $ contexts = Yii :: $ context -> getContextData ( ) ; foreach ( $ contexts as $ context ) { /** @var Application $application */ $ application = $ context [ Context :: COROUTINE_APP ] ?? null ; if ( empty ( $ application ) ) { continue ; } $ targets = $ application -> getLog ( ) -> targets ; foreach ( $ targets as $ target ) { $ target -> export ( ) ; } } }
To flush Log into LogTargets
@param SwooleServer $server
@param $worker_id
To flush Log into LogTargets