E
E
Elena Stepanova2016-04-06 09:34:54
Yii
Elena Stepanova, 2016-04-06 09:34:54

Is there an easy way to expand the number of logging levels (yii2)?

without pandemonium with redefinition of everything and everything
confuses in \yii\log\Target base

public function setLevels($levels)
    {
        static $levelMap = [
            'error' => Logger::LEVEL_ERROR,
            'warning' => Logger::LEVEL_WARNING,
            'info' => Logger::LEVEL_INFO,
            'trace' => Logger::LEVEL_TRACE,
            'profile' => Logger::LEVEL_PROFILE,
        ];
        if (is_array($levels)) {
            $this->_levels = 0;
            foreach ($levels as $level) {
                if (isset($levelMap[$level])) {
                    $this->_levels |= $levelMap[$level];
                } else {
                    throw new InvalidConfigException("Unrecognized level: $level");
                }
            }
        } else {
            $this->_levels = $levels;
        }
    }

Or maybe there is an adequate PSR -3 adaptation with a handler in the web\console\Db with an adjustable reset time

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2016-04-06
@karminski

The number of logging levels is actually set in your application's config, namely in the `traceLevel` parameter of the `log` component:

'log' => [
        'traceLevel' => 3,
    ],

E
Elena Stepanova, 2016-04-06
@Insolita

not trace level, but levels like info, error, warning etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question