/** * We try to serialize and deserialize a random object to make sure no exceptions are thrown. * @see THRIFT-1579 */ public function testBinarySerializer() { $struct = new \ThriftTest\Xtruct(array('string_thing' => 'abc')); $serialized = TBinarySerializer::serialize($struct, 'ThriftTest\\Xtruct'); $deserialized = TBinarySerializer::deserialize($serialized, 'ThriftTest\\Xtruct'); $this->assertEquals($struct, $deserialized); }
public function netlog_send($level, $msg, $tag) { $appid = $this->_appid; try { $current_time = round(microtime(true) * 1000); $content = array('appid' => $appid, 'timestamp' => $current_time, 'msg' => $msg, 'level' => $level); if ($tag !== null && $tag !== '') { $content['tag'] = $tag; } $userEntry = new logchain\UserLogEntry($content); $logBin = TBinarySerializer::serialize($userEntry); $log['content'] = $logBin; $log['category'] = 'user'; $logEntry = new logchain\BaeLogEntry($log); $this->msgArray[] = $logEntry; $baeLog['messages'] = $this->msgArray; $secInfo['user'] = $this->_secret['user']; $secInfo['passwd'] = $this->_secret['passwd']; $secret = new logchain\SecretEntry($secInfo); $baeLog['secret'] = $secret; $baeEntry = new logchain\BaeLog($baeLog); $result = $this->_client->log($baeEntry); $this->_code = $result; if ($result == logchain\BaeRet::OK) { $this->msgArray = array(); return true; } if (count($this->msgArray) >= 256) { $this->msgArray = array(); } return false; } catch (TException $tx) { return false; } }