V
V
Vmedmen2017-09-12 19:47:24
Yii
Vmedmen, 2017-09-12 19:47:24

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;
        }

    }


}

Runs ./yii test-worker
Adding a new task
Yii::$app->beanstalk->putInTube('log', $data, 100, 0);

Notes:
- Logging works without problems in other controllers inherited from yii\console\Controller
- The TestWorkerController worker itself also works well and performs all tasks (except logging).
Please suggest a way to solve this problem.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question