/** * Calls the named method which is not a class method. * * This method will check whether PSR-3 or Yii2 format is used and will execute the corresponding method. * * @param string $name The method name. * @param array $arguments Method arguments. * * @return mixed The method return value. */ public function __call($name, array $arguments) { // Intercept calls to the "log()" method if ($name === 'log' && !empty($arguments)) { // PSR-3 format $reflection = new ReflectionClass(YiiLogger::className()); if (in_array($arguments[0], array_keys($this->_monolog->getLevels())) && !in_array($arguments[1], array_keys($reflection->getConstants())) && (!isset($arguments[3]) || isset($arguments[3]) && is_array($arguments[3]))) { return call_user_func_array([$this, 'log'], $arguments); } // Yii2 format return call_user_func_array([$this, 'yiiLog'], $arguments); } // Execute Monolog methods, if they exists if (method_exists($this->_monolog, $name) && !method_exists($this, $name)) { return call_user_func_array([$this->_monolog, $name], $arguments); } return parent::__call($name, $arguments); }