本文整理汇总了PHP中Zend_Log::setEventItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::setEventItem方法的具体用法?PHP Zend_Log::setEventItem怎么用?PHP Zend_Log::setEventItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::setEventItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: errorAction
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
break;
}
// log exception to database
$db = Zend_Registry::get('db');
$columnMapping = array('priority' => 'priority', 'type' => 'type', 'message' => 'message', 'user' => 'user', 'ip' => 'ip', 'agent' => 'agent', 'url' => 'url');
$user = Zend_Auth::getInstance()->hasIdentity() ? Zend_Auth::getInstance()->getIdentity()->getEmail() : 'anonymous';
$writer = new Zend_Log_Writer_Db($db, 'Logs', $columnMapping);
$logger = new Zend_Log($writer);
$logger->setEventItem('user', $user);
$logger->setEventItem('ip', $_SERVER['REMOTE_ADDR']);
$logger->setEventItem('agent', $_SERVER['HTTP_USER_AGENT']);
$logger->setEventItem('url', $this->view->url());
$logger->setEventItem('type', $errors->type);
$logger->err($errors->exception);
}
示例2: getLogger
/**
* Get the logger instance
*
* @return Zend_Log
*/
public function getLogger()
{
if (is_null($this->_oLogger)) {
$this->_oLogger = Zend_Registry::get('log');
$this->_oLogger->setEventItem('file', get_class($this));
}
return $this->_oLogger;
}
示例3: errorAction
public function errorAction()
{
/**
* Check database connection
*/
try {
$db = Zend_Registry::get('db');
$db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {
// perhaps a failed login credential, or perhaps the RDBMS is not running
$this->databaseError($e);
} catch (Zend_Exception $e) {
// perhaps factory() failed to load the specified Adapter class
$this->databaseError($e);
}
/**
* Normal error page
*/
$pageProxy = new SxCms_Page_Proxy();
$page = $pageProxy->getPageById(36);
$this->view->page = $page;
$this->view->lng = isset($_SESSION['System']['lng']) ? $_SESSION['System']['lng'] : $this->_getParam('lng', 'nl');
$this->_helper->layout->setLayout('full');
$this->view->errorpage = true;
$this->view->glob_tmx = new Zend_Translate('tmx', APPLICATION_ROOT . '/application/var/locale/global.tmx', $this->_getParam('lng', 'nl'));
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->render('404');
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
break;
}
// log exception to database
$db = Zend_Registry::get('db');
$columnMapping = array('priority' => 'priority', 'type' => 'type', 'message' => 'message', 'user' => 'user', 'ip' => 'ip', 'agent' => 'agent', 'url' => 'url');
$user = Zend_Auth::getInstance()->hasIdentity() ? Zend_Auth::getInstance()->getIdentity()->getEmail() : 'anonymous';
$writer = new Zend_Log_Writer_Db($db, 'Logs', $columnMapping);
$logger = new Zend_Log($writer);
$logger->setEventItem('user', $user);
$logger->setEventItem('ip', $_SERVER['REMOTE_ADDR']);
$logger->setEventItem('agent', $_SERVER['HTTP_USER_AGENT']);
$logger->setEventItem('url', $this->view->url());
$logger->setEventItem('type', $errors->type);
$logger->err($errors->exception);
}
示例4: _initLog
protected function _initLog()
{
$log = new Zend_Log();
$log->setEventItem('domain', 'error');
// Non-production
if (APPLICATION_ENV !== 'production') {
$log->addWriter(new Zend_Log_Writer_Firebug());
}
// Get log config
try {
$log->addWriter(new Zend_Log_Writer_Stream(WEB_ROOT . '/temporary/log/main.log'));
} catch (Exception $e) {
// Check directory
if (!@is_dir(WEB_ROOT . '/temporary/log') && @mkdir(WEB_ROOT . '/temporary/log', 0777, true)) {
$log->addWriter(new Zend_Log_Writer_Stream(WEB_ROOT . '/temporary/log/main.log'));
} else {
// Silence ...
if (APPLICATION_ENV !== 'production') {
$log->log($e->__toString(), Zend_Log::CRIT);
} else {
// Make sure logging doesn't cause exceptions
$log->addWriter(new Zend_Log_Writer_Null());
}
}
}
// Save to registry
Zend_Registry::set('Zend_Log', $log);
return $log;
}
示例5: getLogger
public static function getLogger(Zend_Config $config = null)
{
$logger = new Zend_Log();
$hasWriters = false;
if ($config !== null && $config->writers !== null) {
foreach ($config->writers as $writerConfig) {
$writer = self::getWriter($writerConfig);
if ($writer !== null) {
$logger->addWriter($writer);
$hasWriters = true;
}
}
}
if (!$hasWriters) {
$logger->addWriter(new Zend_Log_Writer_Null());
}
// to turn off logging without making the logger throw exceptions
if ($config !== null && $config->eventItems !== null) {
foreach ($config->eventItems as $eventItemName => $eventItemClass) {
$eventItemClass = (string) $eventItemClass;
if (class_exists($eventItemClass)) {
$logger->setEventItem($eventItemName, new $eventItemClass());
}
}
}
return $logger;
}
示例6: saveLogBD
protected function saveLogBD($errors)
{
$config = new Zend_Config_Ini('application/configs/application.ini', APPLICATION_ENV);
$params = array('host' => $config->resources->db->params->host, 'username' => $config->resources->db->params->username, 'password' => $config->resources->db->params->password, 'dbname' => "estatisticas", 'charset' => $config->resources->db->params->charset);
$db = Zend_Db::factory('PDO_MYSQL', $params);
$columnMapping = array('message' => 'message', 'file' => 'file', 'line' => 'line', 'url' => 'url', 'date' => 'date');
$writer = new Zend_Log_Writer_Db($db, 'erro_log', $columnMapping);
$logger = new Zend_Log($writer);
$exception = $errors->exception;
$exception->getTraceAsString();
$logger->setEventItem('message', $exception->getMessage());
$logger->setEventItem('file', $errors->getFile());
$logger->setEventItem('line', $errors->getLine());
$logger->setEventItem('url', $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$logger->setEventItem('date', new Zend_Db_Expr('NOW()'));
$logger->info("Erros");
}
示例7: _initLog
protected function _initLog()
{
$options = $this->getOptions();
$sqs = $this->getResource('AmazonSqs');
$queue_name = $options['amazon']['sqs']['queues']['log'];
$logger = new Zend_Log();
$writer = new JW_Log_Writer_AmazonSqs($sqs, $queue_name);
$logger->addWriter($writer);
$logger->setEventItem('serverHostname', $_SERVER['SERVER_NAME']);
Zend_Registry::set('logger', $logger);
return $logger;
}
示例8: doLog
/**
* Schreibt einen Log-Eintrag
*
* @param string $method Funktions- oder Methodenname
* @param int $line Zeilennummer
* @param string $message Meldung
* @param mixed $data Zusaetzliche Informationen
* @param int $priority Level
* @param string $logid ID des Logeintrag
*/
protected function doLog($method, $line, $message, $data, $priority, $logid = '')
{
if ((int) $priority > (int) $this->level) {
return;
}
$this->logger->setEventItem('data', isset($data) ? print_r($data, true) : null);
$this->logger->setEventItem('method', $method);
$this->logger->setEventItem('line', $line);
$this->logger->setEventItem('logid', $logid);
$this->logger->setEventItem('sessionId', session_id());
$this->logger->log($message, $priority);
}
示例9: log
/**
* @param string $websiteId
* @param string $id
* @param string $name
* @param string $additionalinfo
* @param integer $timestamp
* @param string $userid
* @param string $action
* @param integer $priority
*/
protected function log($websiteId, $id, $name, $additionalinfo, $timestamp, $userlogin, $action, $priority = \Zend_Log::INFO)
{
if ((int) $priority > (int) $this->level) {
return;
}
$this->logger->setEventItem('websiteid', $websiteId);
$this->logger->setEventItem('id', $id);
$this->logger->setEventItem('name', $name);
$this->logger->setEventItem('additionalinfo', $additionalinfo);
$this->logger->setEventItem('timestamp', $timestamp);
$this->logger->setEventItem('userlogin', $userlogin);
$this->logger->setEventItem('action', $action);
$this->logger->log($action, $priority);
}
示例10: init
public function init()
{
$this->getBootstrap()->bootstrap(array('db'));
$tbl = 'tbl_ot_log';
$application = $this->getBootstrap()->getApplication();
$prefix = $application->getOption('tablePrefix');
if (!empty($prefix)) {
$tbl = $prefix . $tbl;
}
// Setup logger
if ($this->_useLog) {
$adapter = Zend_Db_Table::getDefaultAdapter();
$writer = new Zend_Log_Writer_Db($adapter, $tbl);
} else {
$writer = new Zend_Log_Writer_Null();
}
$logger = new Zend_Log($writer);
$logger->addPriority('LOGIN', 8);
$logger->setEventItem('sid', session_id());
$logger->setEventItem('timestamp', time());
$logger->setEventItem('request', str_replace(Zend_Controller_Front::getInstance()->getBaseUrl(), '', $_SERVER['REQUEST_URI']));
Zend_Registry::set('logger', $logger);
}
示例11: __construct
/**
* Construtor Padrão da Classe
*/
private function __construct()
{
$logger = new Zend_Log();
// Adicionar Escritor de Banco de Dados
$mapper = array('ip' => 'address', 'info' => 'info', 'content' => 'message', 'created' => 'timestamp', 'idpeople' => 'user', 'priority' => 'priority', 'priorityname' => 'priorityName');
$table = new Blog_Model_DbTable_Message();
$adapter = $table->getAdapter();
$tableName = $table->info(Zend_Db_Table::NAME);
$element = new Zend_Log_Writer_Db($adapter, $tableName, $mapper);
$logger->addWriter($element);
// Elemento Extra: Identificador do Usuário
$user = null;
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$user = $auth->getIdentity()->idpeople;
}
$logger->setEventItem('user', $user);
// Elemento Extra: IP do Cliente
$front = Zend_Controller_Front::getInstance();
$address = $front->getRequest()->getClientIp();
$logger->setEventItem('address', $address);
$this->_setLogger($logger);
}
示例12: bootstrap
/**
* Initialisiert bei jedem Request das Zend_Log Objekt
*/
public function bootstrap()
{
$configLog = new Dragon_Application_Config('dragonx/log/log');
$logger = new Zend_Log();
foreach ($configLog->eventitems as $name => $value) {
$logger->setEventItem($name, $value);
}
foreach ($configLog->writers as $writer) {
$logger->addWriter($writer);
}
foreach ($configLog->filters as $filter) {
$logger->addFilter($filter);
}
Zend_Registry::set('Zend_Log', $logger);
}
示例13: _setLog
/**
* set logger
*/
protected function _setLog()
{
if (null === self::$_log) {
self::$_log = new SP_Log();
self::$_log->setEventItem('pid', getmypid());
$format = '%timestamp% pid(%pid%) %priorityName% (%priority%): %message%' . PHP_EOL;
$formatter = new Zend_Log_Formatter_Simple($format);
$log_file = SP_APP_PATH . DIRECTORY_SEPARATOR . 'log/log.txt';
$writer_file = new Zend_Log_Writer_Stream($log_file);
$writer_file->setFormatter($formatter);
$writer_firebug = new Zend_Log_Writer_Firebug();
self::$_log->addWriter($writer_file);
self::$_log->addWriter($writer_firebug);
self::$_log->addFilter(new Zend_Log_Filter_Priority(Zend_Log::INFO));
}
Zend_Registry::set('logger', self::$_log);
}
示例14: testLogWritesAndOverwritesExtraFields
public function testLogWritesAndOverwritesExtraFields()
{
$logger = new Zend_Log($mock = new Zend_Log_Writer_Mock());
$logger->setEventItem('foo', 42);
$logger->setEventItem($field = 'bar', $value = 43);
$logger->info('foo');
$this->assertEquals(1, count($mock->events));
$event = array_shift($mock->events);
$this->assertTrue(array_key_exists($field, $event));
$this->assertEquals($value, $event[$field]);
}
示例15: sendMassMailingAction
//.........这里部分代码省略.........
$this->view->assign('unsubscribeLink', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8));
$this->view->assign('subscribeLink', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8, $releaseLanguage));
$this->view->assign('archiveLink', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8, $releaseLanguage));
//$this->view->assign('details_release', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8) . "/ID/" . $release['NR_ID']);
$this->view->assign('details_release', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8, $releaseLanguage) . "/" . $date_string_url . "/" . $release['NR_Title']);
$this->view->assign('details_page', Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_article', 8));
$this->view->assign('isOnline', $release['NR_Online']);
$this->view->assign('newsletterID', $release['NR_ID']);
$this->view->assign('memberId', $members[$k]['GP_MemberID']);
$this->view->assign('moduleId', $this->_moduleID);
$this->view->assign('dateString', $date_string);
$this->view->assign('parutionDate', $date_string_url);
$bodyText = $this->view->render($release['NM_DirectoryEmail']);
$salutationsSelect = new Salutations();
$select = $salutationsSelect->select()->setIntegrityCheck(false);
$salutationId = $members[$k]['GP_Salutation'];
if (is_null($salutationId)) {
$salutationId = 0;
}
$select->from('Salutations')->join('Static_Texts', 'ST_Identifier = S_StaticTitle')->where('ST_LangID = ?', Zend_Registry::get("languageID"))->where('S_ID = ?', $salutationId);
$salutationsData = $salutationsSelect->fetchRow($select);
$bodyText = str_replace('#prenom#', $members[$k]['GP_FirstName'], $bodyText);
$bodyText = str_replace('#nom#', $members[$k]['GP_LastName'], $bodyText);
$bodyText = str_replace('#courtoisie#', $salutationsData['ST_Value'], $bodyText);
//$newsletterData['NR_AfficherTitre'] = $form->getValue('NR_AfficherTitre');
$newsletterAfficherTitre = $release['NR_AfficherTitre'];
$newsletterTextIntro = $release['NR_TextIntro'];
$newsletterTextIntro = str_replace('##prenom##', $members[$k]['GP_FirstName'], $newsletterTextIntro);
$newsletterTextIntro = str_replace('##nom##', $members[$k]['GP_LastName'], $newsletterTextIntro);
$newsletterTextIntro = str_replace('##salutation##', $salutationsData['ST_Value'], $newsletterTextIntro);
$this->view->intro = $newsletterTextIntro;
$this->view->newsletterAfficherTitre = $newsletterAfficherTitre;
$mail = new Zend_Mail();
$mail->setBodyHtml($bodyText);
$mail->setFrom($release['NM_FromEmail'], $release['NMI_FromName']);
$mail->addTo($members[$k]['GP_Email']);
$mail->setSubject($release['NR_Title']);
if (!$mail->send()) {
array_push($failedEmailAddress, array('fname' => $members[$k]['GP_FirstName'], 'lname' => $members[$k]['GP_LastName'], 'email' => $members[$k]['GP_Email']));
}
$sentToCount++;
$releaseMember = new NewsletterReleasesMembers();
$releaseMemberData = $releaseMember->createRow();
$releaseMemberData['NRM_ReleaseID'] = $release['NR_ID'];
$releaseMemberData['NRM_MemberID'] = $members[$k]['GP_MemberID'];
$releaseMemberData['NRM_DateTimeReceived'] = date('Y-m-d H:i:s');
$insert = $releaseMemberData->save();
$i++;
} else {
array_push($failedEmailAddress, array('fname' => $members[$k]['GP_FirstName'], 'lname' => $members[$k]['GP_LastName'], 'email' => $members[$k]['GP_Email']));
}
} catch (Exception $exc) {
$index = $releaseID . '-';
$index .= $k + 1 . '-';
$index .= $members[$k]['GP_MemberID'];
$mailLog[$index]['message'] = $exc->getCode() . '-' . $exc->getFile() . '-' . $exc->getLine();
$mailLog[$index]['log'] = $protocol->getResponse();
$columnsMap = array('NEL_IdIndex' => 'NEL_IdIndex', 'NEL_CodeFileLine' => 'NEL_CodeFileLine', 'NEL_Response' => 'NEL_Response', 'NEL_Timestamp' => 'timestamp');
$writer = new Zend_Log_Writer_Db($this->_db, 'Newsletter_ErrorsLog', $columnsMap);
$oZLog = new Zend_Log($writer);
$oZLog->setEventItem('NEL_IdIndex', $index);
$oZLog->setEventItem('NEL_CodeFileLine', $mailLog[$index]['message']);
$oZLog->setEventItem('NEL_Response', $mailLog[$index]['log'][0]);
$oZLog->log('errors', 4);
}
}
$protocol->quit();
$protocol->disconnect();
} else {
echo Zend_Json::encode(array('sentTo' => '0', 'targetedTotal' => '0', 'failedEmail' => array(), 'select' => $selection));
break;
}
$stats['sentTo'] = $sentToCount;
$dateTimeEnd = date('Y-m-d H:i:s');
$release['NR_MailingDateTimeStart'] = $dateTimeStart;
$release['NR_MailingDateTimeEnd'] = $dateTimeEnd;
$release['NR_SendTo'] = $stats['action'] == 'set' ? $stats['sentTo'] : $release['NR_SendTo'] + $stats['sentTo'];
$release['NR_TargetedTotal'] = $stats['action'] == 'set' ? $stats['targetedTotal'] : $release['NR_TargetedTotal'] + $stats['targetedTotal'];
$release['NR_Status'] = 1;
$release->save();
if (count($failedEmailAddress) > 0) {
$this->_recordEmails($failedEmailAddress, $releaseID);
}
$this->_stats = array('invalidEmails' => count($failedEmailAddress), 'errors' => count($mailLog), 'totalToSend' => $stats['targetedTotal'], 'totalSent' => $stats['sentTo']);
if ($this->_isXmlHttpRequest) {
array_push($listSent, $release['NR_Title']);
array_push($listIds, $release['NR_ID']);
array_push($listDest, $release['NR_AdminEmail']);
$data = array('list' => $listSent, 'dest' => $listDest, 'ids' => $listIds);
$this->_adminNotification($data);
$this->_logSending($data);
}
echo Zend_Json::encode(array('sentTo' => $stats['sentTo'], 'targetedTotal' => $stats['targetedTotal'], 'failedEmail' => $failedEmailAddress, 'select' => $selection));
exit;
}
// If all the newsletter have a status = 1, we don't pass through the foreach
// So redirect the action to the newsletter
// echo(Zend_Json::encode(array('sentTo' => '0', 'targetedTotal' => '0', 'failedEmail' => array(), 'select' => '')));
// exit;
}