*/ class tao_actions_Log extends \tao_actions_CommonModule { /** * Log the message sent from client side */ public function log() { $result = []; if ($this->hasRequestParameter('messages')) { $messages = json_decode($this->getRawParameter('messages'), true); foreach ($messages as $message) { \common_Logger::singleton()->log($this->getLevel($message['level']), json_encode($message), ['frontend']); } } $this->returnJson($result); } /** * Map log level * @todo make it compatible with PRS-3 log levels * @param $level * @return int */ private function getLevel($level) { $result = \common_Logger::TRACE_LEVEL; switch ($level) { case 'fatal': $result = \common_Logger::FATAL_LEVEL; break; case 'error': $result = \common_Logger::ERROR_LEVEL; break; case 'warn': $result = \common_Logger::WARNING_LEVEL; break; case 'info': $result = \common_Logger::INFO_LEVEL; break; case 'debug': $result = \common_Logger::DEBUG_LEVEL; break; case 'trace': $result = \common_Logger::DEBUG_LEVEL; break; } return $result; } }