Answer the question
In order to leave comments, you need to log in
Yii2. Problem with logging in a console controller running in a loop. How can you decide?
Hi all.
In a nutshell: There is a console controller inherited from BeanstalkController .
The problem is that static methods for logging do not work. Yii::info('message', 'category');
Now more.
Controller code
class TestWorkerController extends BeanstalkController
{
const DELAY_PRIORITY = "1000";
const DELAY_TIME = 1;
const DELAY_MAX = 3;
public function listenTubes()
{
return ['log'];
}
public function actionLog($job)
{
$data = $job->getData();
print_r($data);
\Yii::info('111111', 'cat');
try {
\Yii::info('222222', 'cat');
return self::DELETE;
} catch (\Exception $e) {
fwrite(STDERR, Console::ansiFormat($e . "\n", [Console::FG_BLUE]));
return self::BURY;
}
}
}
Yii::$app->beanstalk->putInTube('log', $data, 100, 0);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question