本文整理汇总了PHP中Zend_Log::err方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::err方法的具体用法?PHP Zend_Log::err怎么用?PHP Zend_Log::err使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::err方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWrite
public function testWrite()
{
$this->log->err('123');
$this->log->info('123');
$count = $this->rediska->getListLength('log');
$this->assertEquals(2, $count);
}
示例2: deliverOrder
/**
* Performs order delivery for the provided orderId.
*
* @param int $orderId The unique identifier of the order.
* @return void
*/
public function deliverOrder($orderId)
{
try {
$order = $this->_repository->getById($orderId);
// TODO: Do something useful with the order.
$this->_notifier->notifyCustomerOfDelivery($order->getCustomer(), $order);
} catch (\Exception $e) {
$this->_logger->err('An error occurred while delivering the order: ' . $e->getMessage(), $e);
}
}
示例3: sendFileViaFpassthru
/**
* Delivers the file via function "fpassthru()".
*
* @param string $file
*/
private function sendFileViaFpassthru($file)
{
$response = $this->getResponse();
$response->setHttpResponseCode(200);
if (!is_null($this->logger)) {
$content = ob_get_contents();
if (!empty($content)) {
$this->logger->err($content);
}
}
ob_end_clean();
set_time_limit(300);
$modified = filemtime($file);
$response->setHeader('Last-Modified', gmdate('r', $modified), true);
$response->setHeader('Content-Length', filesize($file), true);
$response->sendHeaders();
$fp = fopen($file, 'rb');
if ($fp === false) {
throw new Exception('fopen failed.');
}
$retval = fpassthru($fp);
if ($retval === false) {
throw new Exception('fpassthru failed.');
}
fclose($fp);
exit;
}
示例4: 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);
}
示例5: search
/**
*
* @param Opus_SolrSearch_Query $query
* @param bool $validateDocIds check document IDs coming from Solr index against database
* @return Opus_SolrSearch_ResultList
* @throws Opus_SolrSearch Exception If Solr server responds with an error or the response is empty.
*/
public function search($query, $validateDocIds = true)
{
/**
* @var Apache_Solr_Response $solr_response
*/
$solr_response = null;
try {
$this->log->debug("query: " . $query->getQ());
$solr_response = $this->solr_server->search($query->getQ(), $query->getStart(), $query->getRows(), $this->getParams($query));
} catch (Exception $e) {
$msg = 'Solr server responds with an error ' . $e->getMessage();
$this->log->err($msg);
if ($e instanceof Apache_Solr_HttpTransportException) {
if ($e->getResponse()->getHttpStatus() == '400') {
// 400 seems to indicate org.apache.lucene.query.ParserParseException
throw new Opus_SolrSearch_Exception($msg, Opus_SolrSearch_Exception::INVALID_QUERY, $e);
}
if ($e->getResponse()->getHttpStatus() == '404') {
// 404 seems to indicate Solr server is unreachable
throw new Opus_SolrSearch_Exception($msg, Opus_SolrSearch_Exception::SERVER_UNREACHABLE, $e);
}
}
throw new Opus_SolrSearch_Exception($msg, null, $e);
}
if (is_null($solr_response)) {
$msg = 'could not get an Apache_Solr_Response object';
$this->log->err($msg);
throw new Opus_SolrSearch_Exception($msg);
}
$responseRenderer = new Opus_SolrSearch_ResponseRenderer($solr_response, $validateDocIds, $query->getSeriesId());
return $responseRenderer->getResultList();
}
示例6: consume
/**
* Execute a job and remove it from the jobs table on success.
*
* @param Opus_Job $job Job description model.
* @return boolean Returns true if a job is consumend false if not
*/
protected function consume(Opus_Job $job)
{
$label = $job->getLabel();
if ($job->getState() !== null) {
return false;
}
if (array_key_exists($label, $this->_workers)) {
$worker = $this->_workers[$label];
if (null !== $this->_logger) {
$this->_logger->info('Processing ' . $label);
}
$job->setState(Opus_Job::STATE_PROCESSING);
$job->store();
try {
$worker->setLogger($this->_logger);
$worker->work($job);
$job->delete();
sleep($this->_delay);
} catch (Exception $ex) {
if (null !== $this->_logger) {
$msg = get_class($worker) . ': ' . $ex->getMessage();
$this->_logger->err($msg);
}
$job->setErrors(json_encode(array('exception' => get_class($ex), 'message' => $ex->getMessage(), 'trace' => $ex->getTraceAsString())));
$job->setState(Opus_Job::STATE_FAILED);
$job->store();
return false;
}
return true;
}
return false;
}
示例7: errorAction
public function errorAction()
{
$http_accept = $_SERVER['HTTP_ACCEPT'];
$this->_redirecUnknownImage($http_accept);
$errors = $this->_getParam('error_handler');
$msg = $errors->exception->getMessage();
$backTrace = $errors->exception->getTraceAsString();
$this->_handleMessage($errors);
$this->_helper->viewRenderer->setViewScriptPathSpec('error/' . $this->getResponse()->getHttpResponseCode() . '.:suffix');
$this->view->exception = $errors->exception;
$this->view->request = $errors->request;
$this->view->ui = 1;
$logPath = realpath(APPLICATION_PATH . '/../log') . "/error";
if (!is_dir($logPath)) {
mkdir($logPath, 755, TRUE);
}
$log = new Zend_Log(new Zend_Log_Writer_Stream($logPath . "/" . date("Ymd") . "_applicationException.log"));
$params1 = $this->_request->getParams();
unset($params1["error_handler"]);
$params = Zend_Json::encode($params1);
$messages = array($msg, $backTrace, $params, "HTTP_ACCEPT: " . $http_accept, "");
$log->err(implode(self::LOG_EOL, $messages));
try {
self::$_dispatcher->notify(new sfEvent($this, 'error.log', array('message' => array($msg, $backTrace), 'priority' => 3)));
return;
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例8: addItem
public static function addItem($message, $error = false)
{
global $s1b;
if (self::getConfig()->getTracesEnabled() || self::getConfig()->getLogsEnabled()) {
if (!strlen(trim($message))) {
throw new \Exception('Cannot insert empty trace.');
}
// Ecriture du message dans le tableau des items en sessions si traces activées
if (self::getConfig()->getTracesEnabled()) {
self::initItems();
self::$items[] = $message;
}
// Ecriture du log si activé
if (self::getConfig()->getLogsEnabled()) {
// vérification de l'existence du fichier et création si non existant
$now = new \DateTime();
$logFilePath = self::getContext()->getBaseDirectory() . sprintf("/var/log/%s-log.txt", $now->format("Ymd"));
if (!file_exists($logFilePath)) {
$file = fopen($logFilePath, "w");
fclose($file);
}
// ecriture du log dans le fichier
$writer = new \Zend_Log_Writer_Stream($logFilePath);
$logger = new \Zend_Log($writer);
if ($error) {
$logger->err($message);
} else {
$logger->info($message);
}
$logger = null;
}
}
}
示例9: log
/**
* Logs a message to the error log along with its trace.
* The backtrace is automatically retrieved, even if the entry is a string, so NO backtrace
* information should be provided in the message. However, if you need to save other context
* data, as the URL, HTTP headers, or ENV variables, these should be part of the message.
*
* @param mixed $entry Can be of type string, ErrorException or Exception
* @param int $priority One of the Cli_Service_Log class constants.
* @param bool $addTrace Whether to add a trace to log message.
*/
public static function log($entry, $priority = self::ERR, $addTrace = true)
{
if (!self::$_logger) {
self::$_logger = Zend_Registry::get('errorLog');
}
$logData = array('message' => '', 'priority' => $priority);
if ($entry instanceof ErrorException) {
$severity = $entry->getSeverity();
switch ($severity) {
case E_NOTICE:
$logData['priority'] = self::NOTICE;
break;
case E_WARNING:
$logData['priority'] = self::WARN;
break;
case E_ERROR:
default:
$logData['priority'] = self::ERR;
break;
}
if ($addTrace) {
$logData['message'] = '';
$traceString = str_replace("#", "\t#", $entry->getTraceAsString());
$logData['message'] .= $entry->getMessage() . PHP_EOL . $traceString . PHP_EOL;
} else {
$logData['message'] = $entry->getMessage();
}
} elseif ($entry instanceof Exception) {
// add a tab beofre each new line of the trace string
$logData['priority'] = $entry->getCode();
if ($addTrace) {
$logData['message'] = '';
$traceString = str_replace("#", "\t#", $entry->getTraceAsString());
$logData['message'] .= $entry->getMessage() . PHP_EOL . $traceString . PHP_EOL;
} else {
$logData['message'] = $entry->getMessage();
}
} elseif (is_string($entry)) {
if ($addTrace) {
$rawBacktrace = debug_backtrace();
$formattedBacktrace = self::_getFormattedBacktrace($rawBacktrace);
$logData['message'] = $entry . PHP_EOL . $formattedBacktrace;
} else {
$logData['message'] = $entry;
}
} else {
throw new BadMethodCallException('Logging service called with unknown entry type: ' . gettype($entry));
}
if ($logData['priority'] >= self::EMERG && $logData['priority'] <= self::DEBUG) {
self::$_logger->log($logData['message'], $logData['priority']);
} else {
self::$_logger->err($logData['message']);
}
if (ini_get('display_errors')) {
echo $logData['message'] . PHP_EOL;
}
}
示例10: optimize
/**
* Optimizes the index
*
* @throws Opus_SolrSearch_Index_Exception If index optimization failed.
* @return void
*/
public function optimize()
{
try {
$this->getSolrServer('index')->optimize();
} catch (Apache_Solr_Exception $e) {
$msg = 'Error while performing index optimization';
$this->log->err("{$msg} : " . $e->getMessage());
throw new Opus_SolrSearch_Index_Exception($msg, 0, $e);
}
}
示例11: 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);
}
示例12: __construct
public function __construct($results = array(), $numberOfHits = 0, $queryTime = 0, $facets = array(), $validateDocIds = true, $log = null)
{
$this->log = $log;
$this->numberOfHits = $numberOfHits;
$this->queryTime = $queryTime;
$this->facets = $facets;
$this->results = array();
// make sure that documents returned from index exist in database
if (!empty($results)) {
if ($validateDocIds) {
$docIds = array();
foreach ($results as $result) {
array_push($docIds, $result->getId());
}
$finder = new Opus_DocumentFinder();
$finder->setServerState('published');
$finder->setIdSubset($docIds);
$docIdsDB = $finder->ids();
$notInDB = 0;
foreach ($results as $result) {
if (in_array($result->getId(), $docIdsDB)) {
array_push($this->results, $result);
} else {
$notInDB++;
}
}
$resultsSize = count($this->results);
if ($notInDB > 0 && !is_null($this->log)) {
$inDB = $resultsSize - $notInDB;
$this->log->err("found inconsistency between database and solr index: index returns {$resultsSize} documents, but only " . $inDB . " found in database");
}
} else {
$this->results = $results;
}
}
}
示例13: addReadFilePrivilege
/**
* Add readFile privilege to all files of this document.
*
* @param string $roleName
* @return Matheon_Model_Document Fluent interface.
*/
public function addReadFilePrivilege($roleName = 'guest')
{
$role = Opus_UserRole::fetchByName($roleName);
if (is_null($role)) {
$this->_log->err("Cannot add readFile privilege for non-existent role '{$role->getName()}' to document " . $this->getId() . ".");
return $this;
}
$this->_log->warn("Warning: Setting all files readable for role '{$role->getName()}' (document " . $this->getId() . ")");
$role->appendAccessDocument($this->getId());
foreach ($this->_document->getFile() as $file) {
$role->appendAccessFile($file->getId());
}
$role->store();
return $this;
}
示例14: receiveMessage
/**
* Receive message
*
* @param AMQPMessage $rabbitMessage Rabbit message
* @param Oggetto_Messenger_Model_Message_Interface $messagePrototype Message prototype
* @param array|Closure $callback Callback
*
* @throws Exception
* @throws Oggetto_Messenger_Exception_Critical
*
* @return void
*/
public function receiveMessage(AMQPMessage $rabbitMessage, Oggetto_Messenger_Model_Message_Interface $messagePrototype, $callback)
{
try {
$this->_logger->info("Received new message: {$rabbitMessage->body}");
$message = clone $messagePrototype;
$message->init($rabbitMessage->body);
call_user_func_array($callback, array($message));
} catch (Oggetto_Messenger_Exception_Critical $e) {
// Only critical exceptions are supposed to stop the receiver
throw $e;
} catch (Exception $e) {
$this->_logger->err($e);
}
$channel = $rabbitMessage->{'delivery_info'}['channel'];
$channel->basic_ack($rabbitMessage->{'delivery_info'}['delivery_tag']);
}
示例15: _zendlog
private function _zendlog()
{
$write = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/log/log.txt');
$format = new Zend_Log_Formatter_Simple('%message%');
$write->setFormatter($format);
$log = new Zend_Log($write);
$log->info('thong bao', Zend_Log::INFO);
$log->err('thong bao loi', Zend_Log::ERR);
// $write= new Zend_Log_Writer_Stream(APPLICATION_PATH.'/log/log.txt');
//
// $log->info('thong bao', Zend_Log::INFO);
// $log->err('thong bao loi', Zend_Log::ERR);
//
//
//
// $log = new Zend_Log($write);
}