I am currently working with zend 2 logger. I have a table error_log
with the following fields:
- error_log_id
- message
- timestamp
- priorityName
- priority
- ip
- user_id
And the following is my code
$db = $this->service->get('Zend\Db\Adapter\Adapter');
$uId = 0;
if ($auth->hasIdentity()) {
$oId = $auth->getIdentity();
$uId = $oId->user_id;
}
$mapping = array(
'timestamp' => 'timestamp',
'priority' => 'priority',
'priorityName' => 'priorityName',
'message' => 'message',
);
$writer = new \Zend\Log\Writer\Db($db, 'error_log_table', $mapping);
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Informational message');
This works fine and the following fields will be updated. timestamp, priority, priorityName, & message.
I also want to update the user_id and ip field. How can i do this? (In zend 1, we can do this by using setEventItem()
function). What function I have to call to add extra parameter in zend 2 log?
Somebody please help?