php對接阿裡日志SLS系統遇到的一些問題
composer update 時報錯
有人建議
composer update --ignore-platform-reqs
--ignore-platform-reqs 這個是忽略php版本比對的意思(當你的PHP不高時候,不要輕易使用這個指令)
單獨引入sdk:
部署流水線
git checkout master
git pull origin master
git checkout ${COMMIT_ID}
#更新composer 依賴
composer config --no-plugins allow-plugins.topthink/think-installer true
#--no-plugins配置允許不安裝插件
composer update
git checkout .#避免引起下次的問題送出沖突
日志Sdk注意事項:
- 當鍵值為NULL 會報錯;
- 當日志的content 裡面有二維數組時,會報strlen錯誤
sls.proto.php檔案需要更新
public function size() {
$size = 0;
if (!is_null($this->key_)) {
$l = strlen($this->key_);
$size += 1 + Protobuf::size_varint($l) + $l;
}
if (!is_null($this->value_)) {
if (is_array($this->value_))
{
$this->value_ = json_encode($this->value_,JSON_UNESCAPED_UNICODE);
}
$l = strlen($this->value_);
$size += 1 + Protobuf::size_varint($l) + $l;
}
return $size;
}
如何查詢:
- nottopic: 通路記錄日志 andtopic: "api/Crm/saveStudent" and phone:18500001111