使用 count 会有 notice
BestKind opened this issue · 0 comments
BestKind commented
使用 sample.php 中的 getLogs 方法,将其中的 query 的为 " query | timeslice 24h | count " 时会有 notice
PHP Notice: Undefined index: source in ******/aliyun-log-php-sdk/Aliyun/Log/Models/Response/GetLogsResponse.php on line 48
sample/sample.php 文件改造如下:
58 function getLogs(Aliyun_Log_Client $client, $project, $logstore) {
59 // $topic = 'TestTopic';
60 $topic = '';
61 $from = time()-86400;
62 $to = time();
63 $query = 'type:adc | timeslice 12h | count';
64 // $query = '';
65 $request = new Aliyun_Log_Models_GetLogsRequest($project, $logstore, $from, $to, $topic, $query, 100, 0, False);
66
67 try {
68 $response = $client->getLogs($request);
69 foreach($response -> getLogs() as $log)
70 {
71 print $log -> getTime()."\t";
72 foreach($log -> getContents() as $key => $value){
73 print $key.":".$value."\t";
74 }
75 print "\n";
76 }
77
78 } catch (Aliyun_Log_Exception $ex) {
79 logVarDump($ex);
80 } catch (Exception $ex) {
81 logVarDump($ex);
82 }
83 }