/** * @param string $level * @param string $message * @param array $context * * @return void * @throws \ManaPHP\Mvc\Model\Exception */ public function log($level, $message, $context = []) { if ($this->_nested) { return; } $this->_nested = true; if ($this->_log === null) { /** * @var \ManaPHP\Logger\Adapter\Db\Model $log */ $log = new $this->_model(); $log->level = $level; $log->user_id = $this->userIdentity->getId(); $log->user_name = $this->userIdentity->getName(); $log->module = $this->dispatcher->getModuleName(); $log->controller = $this->dispatcher->getControllerName(); $log->action = $this->dispatcher->getActionName(); $log->ip = $this->request->getClientAddress(); $this->_log = $log; } $this->_log->log_id = null; $this->_log->message = $message; $this->_log->created_time = time(); $this->_log->create(); $this->_nested = false; }