从昨天开始搞loganalyzer,一直无法显示自己mysql中的日志。
日志表是自定义的。
+---------+---------------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+---------------------+------+-----+-------------------+----------------+ | logId | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | account | char(64) | NO | | | | | server | int(10) unsigned | NO | | 0 | | | device | char(64) | NO | | | | | error | blob | YES | | NULL | | | uID | int(11) | YES | | 0 | | | date | timestamp | NO | | CURRENT_TIMESTAMP | | +---------+---------------------+------+-----+-------------------+----------------+
自己定义datasource,field,view,dbmapping,一切都OK。但就是显示有问题。
如下图所示少了uID那一列的数据。
google了N多资料都无解。
网上也有一个相同现象的帖子,也没有找到原因:http://kb.monitorware.com/reading-custom-mysql-table-t11919.html
一气之外感觉自己debug可能能找到原因。
在classes/logstreamdb.class.php 中
修改readnext方法如下:
if ( $content['MaxExecutionTime'] > 0 && $scriptruntime > ($content['MaxExecutionTime']-2) )
{
// This may display a warning message, so the user knows we stopped reading records because of the script timeout.
$content['logstream_warning'] = "false";
// Run optional Message Parsers now
if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) )
{
$retParser = $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Check if we have to skip the message!
if ( $retParser == ERROR_MSG_SKIPMESSAGE )
$ret = $retParser;
}
// Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum;
echo "<br/>";
echo $dbmapping[$szTableType];
foreach($dbmapping[$szTableType] as $key => $val) {
echo "|".$key."|".$val, '<br>';
}
foreach($dbmapping[$szTableType]['DBMAPPINGS'] as $key => $val) {
echo "|_|".$key."|".$val, '<br>';
}
foreach($this->bufferedRecords[$this->_currentRecordNum] as $key => $val) {
echo "|||".$key."|".$val,"<br/>";
}
echo "SYSLOG_UID:".SYSLOG_UID."<br/>";
echo "hello ". $dbmapping[$szTableType]['DBMAPPINGS']['uID']."world";
echo "hello ". $this->bufferedRecords[$this->_currentRecordNum]['uid']."world";
echo "<br/>";
$uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_UID]];
// Increment $_currentRecordNum
$this->_currentRecordNum++;
}
把debug信息输出后,才发现问题。
uID对应数据中的logId字段,但在this->bufferedRecords中的key全是小写的。你妹的,各个文档上谁也没写要注意这么一个东西。dbmapping直接修改uID改为logid小写后,日志查看bug解决了。
正常的显示:
近期评论