2
我想將包含登錄用戶的用戶ID的字段添加到zend db logger
中。將用戶ID字段添加到zend數據庫記錄器
這裏是我當前的代碼:
$mapping = array(
'timestamp' => 'created',
'priorityName' => 'type',
'message' => 'message'
);
$dbAdapter = Pluto::database()->getMasterAdapter();
$writer = new \Zend\Log\Writer\Db($dbAdapter,'logs',$mapping);
$this->logger->addWriter($writer);
我的用戶ID列將userid
。如果用戶沒有登錄,那麼它應該插入0.
不太確定在這裏做什麼。
UPDATE
這裏是我當前的處理器:
namespace Pluto\Log;
use Zend\Log\Processor\ProcessorInterface;
class UserAwareProcessor implements ProcessorInterface
{
/**
* @param array $event event data
* @return array event data
*/
public function process(array $event)
{
if (! isset($event['extra'])) {
$event['extra'] = [];
}
$event['extra']['userid'] = 5;
return $event;
}
}
似乎沒有更新數據庫列用戶標識。檢查我的更新代碼 – jkushner