/** * Provides custom logging functionality for modRegister targets. * * @access protected * @param modRegister $register The modRegister instance to send to * @param int $level The level of error or message that occurred * @param string $msg The message to send to the register * @param string $def The type of error that occurred * @param string $file The filename of the file that the message occurs for * @param string $line The line number of the file that the message occurs for */ protected function _logInRegister($register, $level, $msg, $def, $file, $line) { $timestamp = strftime('%Y-%m-%d %H:%M:%S'); $messageKey = (string) time(); $messageKey .= '-' . sprintf("%06d", $this->_logSequence); $message = array('timestamp' => $timestamp, 'level' => $this->_getLogLevel($level), 'msg' => $msg, 'def' => $def, 'file' => $file, 'line' => $line); $options = array(); if ($level === xPDO::LOG_LEVEL_FATAL) { $options['kill'] = true; } $register->send('', array($messageKey => $message), $options); $this->_logSequence++; }
/** * Subscribe register and send message * @return bool */ public function sendMessage() { $options = array('delay' => (int) $this->getProperty('delay', 0), 'ttl' => (int) $this->getProperty('ttl', 0), 'kill' => (bool) $this->getProperty('kill', false)); $this->register->subscribe($this->topic); return $this->register->send($this->topic, $this->message, $options); }