本文整理汇总了PHP中Zend_Log::debug方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::debug方法的具体用法?PHP Zend_Log::debug怎么用?PHP Zend_Log::debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __destruct
/**
* Show execution time
*/
public function __destruct()
{
if (!$this->log) {
return;
}
$this->log->debug('Complete in ' . round(microtime(true) - $this->_timeStart, 3) . ' seconds. ' . $this->getMemoryUsageNow() . ' of memory used.');
$this->log->debug('== Script execution completed ==');
}
示例2: getFacets
private function getFacets()
{
$config = Zend_Registry::get('Zend_Config');
if (!isset($config->searchengine->solr->facets)) {
$this->log->debug('config parameter searchengine.solr.facets is not defined -- no facets will be displayed');
return array();
}
if (!array_key_exists('facet_counts', $this->jsonResponse) || !array_key_exists('facet_fields', $this->jsonResponse['facet_counts'])) {
return array();
}
$facetsResult = $this->jsonResponse['facet_counts']['facet_fields'];
$facets = explode(",", $config->searchengine->solr->facets);
$result = array();
foreach ($facets as $facet) {
$facet = trim($facet);
$facetItems = array();
foreach ($this->getFacet($facetsResult, $facet) as $text => $count) {
if ($facet == 'year_inverted') {
$valueParts = explode(':', $text, 2);
$text = $valueParts[1];
}
array_push($facetItems, new Opus_SolrSearch_FacetItem($text, $count));
}
if ($facet == 'year_inverted') {
$facet = 'year';
}
$result[$facet] = $facetItems;
}
return $result;
}
示例3: 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();
}
示例4: testLogSimple
public function testLogSimple()
{
$writer = new Zfb_Log_Writer_Rolling_File(dirname(__FILE__) . '/resources/application.log');
$writer->setFileMaxSize("10KB");
$writer->setMaxFiles(10);
$this->zendLog->addWriter($writer);
for ($i = 0; $i < 5; $i++) {
$this->zendLog->debug('testLogSimple - test debug using rolling file : ' . $i);
}
$dir = dirname(__FILE__) . '/resources';
$content = file_get_contents($dir . '/application.log');
$this->assertFileExists($dir . '/application.log');
$this->assertRegExp('~testLogSimple - test debug using rolling file : 0~', $content);
$this->assertRegExp('~testLogSimple - test debug using rolling file : 1~', $content);
$this->assertRegExp('~testLogSimple - test debug using rolling file : 2~', $content);
$this->assertRegExp('~testLogSimple - test debug using rolling file : 3~', $content);
$this->assertRegExp('~testLogSimple - test debug using rolling file : 4~', $content);
}
示例5: sendSolrXmlToServer
/**
* Posts the given xml document to the Solr server without using the solr php client library.
*
* @param DOMDocument $solrXml
* @return void
*/
private function sendSolrXmlToServer($solrXml)
{
$stream = stream_context_create();
stream_context_set_option($stream, array('http' => array('method' => 'POST', 'header' => 'Content-Type: text/xml; charset=UTF-8', 'content' => $solrXml->saveXML(), 'timeout' => '3600')));
$response = new Apache_Solr_Response(@file_get_contents($this->index_server_url . '/update', false, $stream));
$this->log->debug('Solr Response Status: ' . $response->getHttpStatus());
if (!$response->getRawResponse()) {
throw new Opus_SolrSearch_Index_Exception("Solr Server {$this->index_server_url} not responding.");
}
}
示例6: _performRequest
/**
* Performs the HTTP request and parses the result to return the Result Object
*
* @param string $httpMethod
* @return Tid_Zend_REST_Json_Result
*/
protected function _performRequest($httpMethod)
{
// For calculating the time spent in the request
$initTime = microtime(true);
// Perform the HTTP request
$response = self::getHttpClient()->request($httpMethod);
// Log the request and response
if ($this->_logger) {
$requestDuration = (microtime(true) - $initTime) * 1000;
$this->_logger->debug("\nRESTClient request: " . self::getHttpClient()->getLastRequest() . "\n\nRESTClient response: " . round($requestDuration, 2) . "ms\n" . self::getHttpClient()->getLastResponse() . "\n");
}
if ($this->_throwExceptions && $response->isError()) {
/**
* If the client is configured to throw exceptions, parse the HTTP
* response headers to throw the corresponding exception
*/
switch ($response->getStatus()) {
case 400:
require_once 'Tid/Zend/REST/Json/Exception/BadRequest.php';
throw new Tid_Zend_REST_Json_Exception_BadRequest(self::getHttpClient()->getLastResponse(), $response->getStatus());
case 401:
require_once 'Tid/Zend/REST/Json/Exception/Unauthorized.php';
throw new Tid_Zend_REST_Json_Exception_Unauthorized(self::getHttpClient()->getLastResponse(), $response->getStatus());
case 403:
require_once 'Tid/Zend/REST/Json/Exception/Forbidden.php';
throw new Tid_Zend_REST_Json_Exception_Forbidden(self::getHttpClient()->getLastResponse(), $response->getStatus());
case 404:
require_once 'Tid/Zend/REST/Json/Exception/NotFound.php';
throw new Tid_Zend_REST_Json_Exception_NotFound(self::getHttpClient()->getLastResponse(), $response->getStatus());
case 502:
require_once 'Tid/Zend/REST/Json/Exception/BadGateway.php';
throw new Tid_Zend_REST_Json_Exception_BadGateway(self::getHttpClient()->getLastResponse(), $response->getStatus());
case 503:
require_once 'Tid/Zend/REST/Json/Exception/ServiceUnaivailable.php';
throw new Tid_Zend_REST_Json_Exception_ServiceUnavailable(self::getHttpClient()->getLastResponse(), $response->getStatus());
default:
require_once 'Tid/Zend/REST/Json/Exception/InternalError.php';
throw new Tid_Zend_REST_Json_Exception_InternalError(self::getHttpClient()->getLastResponse(), $response->getStatus());
}
}
// Hydrate an object with the result contents
try {
if (!$response->getBody()) {
$result = null;
} else {
require_once 'Zend/Json.php';
$result = Zend_Json::decode($response->getBody(), Zend_Json::TYPE_OBJECT);
}
} catch (Zend_Json_Exception $e) {
require_once 'Tid/Zend/REST/Json/Exception/InvalidFormat.php';
throw new Tid_Zend_REST_Json_Exception_InvalidFormat($response->getBody(), $response->getStatus());
}
require_once 'Tid/Zend/REST/Json/Result.php';
return new Tid_Zend_REST_Json_Result($result, $response->getHeaders(), $response->getStatus(), $response->isSuccessful());
}
示例7: _log
/**
* log something to the logger
*
* @param string $logMessage
*/
protected function _log($logMessage)
{
if ($this->_logger === null) {
return;
}
try {
$this->_logger->debug($logMessage);
} catch (Zend_Log_Exception $zle) {
// the logger stream might have been closed already
}
}
示例8: saveLog
protected function saveLog($errors)
{
$logger = new Zend_Log();
$writer = new Zend_Log_Writer_Stream('application/tmp/erro/error.xml');
$formatter = new Zend_Log_Formatter_Xml();
$writer->setFormatter($formatter);
$logger->addWriter($writer);
$exception = $errors->exception;
$exception->getTraceAsString();
$logger->debug($exception->getMessage() . "\r\n");
}
示例9: rollBack
/**
* perform rollBack on all transactionables with open transactions
*
* @return void
*/
public function rollBack()
{
if ($this->_logger instanceof Zend_Log) {
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " rollBack request, rollBack all transactionables");
}
foreach ($this->_openTransactionables as $transactionable) {
if ($transactionable instanceof Zend_Db_Adapter_Abstract) {
$transactionable->rollBack();
#Tinebase_Backend_Sql_Command::setAutocommit($transactionable,true);
}
}
$this->_openTransactionables = array();
$this->_openTransactions = array();
}
示例10: errorAction
public function errorAction()
{
$errors = $this->_getParam('error_handler');
$exception = $errors->exception;
try {
$log = new Zend_Log(new Zend_Log_Writer_Stream(Axis::config()->system->path . Axis::config()->log->main->php));
$log->debug($exception->getMessage() . "\n" . $exception->getTraceAsString());
} catch (Zend_Log_Exception $e) {
//who cares
}
$this->getResponse()->clearBody();
if ($this->getRequest()->isXmlHttpRequest()) {
Axis::message()->addError($exception->getMessage());
$this->_helper->json->sendFailure();
} else {
$this->view->pageTitle = Axis::translate('admin')->__('Error');
$this->view->error = str_replace("\n", "<br />\n", $exception->getMessage() . "\n" . $exception->getTraceAsString());
$this->render();
}
}
示例11: errorAction
public function errorAction()
{
$errors = $this->_getParam('error_handler');
// Is this a Zend not found exception ?
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
return $this->_forward('notfound', null, null, array('message' => 'No such controller'));
break;
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
return $this->_forward('notfound', null, null, array('message' => 'No such action'));
break;
}
// Application error
$exception = $errors->exception;
// Is this a stuffpress not found exception ?
if (get_class($exception) == 'Stuffpress_NotFoundException') {
return $this->_forward('notfound', null, null, array('message' => $exception->getMessage()));
}
// Is this a stuffpress access denied exception ?
if (get_class($exception) == 'Stuffpress_AccessDeniedException') {
return $this->_forward('denied', null, null, array('message' => $exception->getMessage()));
}
// Log the error
$config = Zend_Registry::get("configuration");
$path = isset($config->path->logs) ? $config->path->logs : Zend_Registry::get("root") . '/logs/';
$root = Zend_Registry::get("root");
$uri = Zend_Registry::isRegistered("uri") ? Zend_Registry::get("uri") : '';
$host = Zend_Registry::isRegistered("host") ? Zend_Registry::get("host") : '';
$log = new Zend_Log(new Zend_Log_Writer_Stream($path . '/applicationException.log'));
$log->debug("Exception for request http://{$host}/{$uri}\n" . $exception->getMessage() . "\n" . $exception->getTraceAsString() . "\n----------------------------\n\n");
// Are we in debug mode ?
$config = Zend_Registry::get("configuration");
$debug = $config->debug;
// Don't forget to clear the response body, just in case
$this->getResponse()->clearBody();
if ($debug) {
$this->view->message = $exception->getMessage();
$this->view->trace = $exception->getTraceAsString();
return $this->render('debug');
}
}
示例12: errorAction
public function errorAction()
{
//error_log('errorAction');
$this->setCanonicalUrl(false);
$this->getResponse()->clearBody();
$errors = $this->_getParam('error_handler');
$exception = $errors->exception;
// log all kind of errors
try {
$log = new Zend_Log(new Zend_Log_Writer_Stream(Axis::config()->system->path . Axis::config()->log->main->php));
$log->debug($exception->getMessage() . "\n" . $exception->getTraceAsString());
} catch (Zend_Log_Exception $e) {
//who cares
}
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
return $this->_forward('not-found');
//return $this->notFoundAction();
//return $this->notFoundAction();
default:
// application error
$this->_helper->layout->setLayout('layout_error');
// hardcoded layout for application errors
$this->getResponse()->setHttpResponseCode(500);
$this->view->pageTitle = Axis::translate('core')->__('An error has occured processing your request');
$this->view->meta()->setTitle($this->view->pageTitle);
if (Axis::app()->getEnvironment() == 'development') {
// $traceAsString = preg_replace(
// '/(#\d+\s)(\/.*\/[^\/]+(?:\.php|\.phtml))/',
//// "<a onclick=\"window.open('file://$2');return false;\">$1$2</a>",
// "<a href=\"file://$2\">$1$2</a>",
// $exception->getTraceAsString()
// );
$this->view->error = str_replace(AXIS_ROOT . '/', '/', $exception->getMessage() . "\n<strong>" . Axis::translate('core')->__('Trace') . ":</strong>\n" . $this->view->escape($exception->getTraceAsString()));
}
break;
}
}
示例13: errorAction
public function errorAction()
{
$errors = $this->_getParam('error_handler');
$exception = $errors->exception;
$message = $exception->getMessage();
$trace = $exception->getTraceAsString();
$controller = trim($this->getRequest()->getParam('controller'));
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
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()->setRawHeader('HTTP/1.1 404 Not Found');
// ... get some output to display...
break;
default:
if (!preg_match('/Invalid controller specified/', $exception->getMessage())) {
// application error; display error page, but don't change
// status code
// Log the exception:
$log = new Zend_Log(new Zend_Log_Writer_Stream(LOG_DIR . '/php-exceptions-' . date('m-d-Y') . '.log'));
$log->debug($exception->getMessage() . "\n" . $exception->getTraceAsString());
}
}
// clear previous content
$this->getResponse()->clearBody();
if (is_array(@$_SESSION['site']['permissions']['admin'])) {
if (in_array('can_view_debug_messages', $_SESSION['site']['permissions']['admin'])) {
$this->view->message = $message;
$this->view->trace = $trace;
} else {
$this->view->message = fetchTranslation('http_error_404_text');
$this->view->trace = null;
}
} else {
$this->view->message = fetchTranslation('http_error_404_text');
$this->view->trace = null;
}
}
示例14: performRedirect
private function performRedirect($action, $message = null, $controller = null, $module = null, $params = array(), $exit = false)
{
if (!is_null($message)) {
if (is_array($message) && count($message) !== 0) {
$keys = array_keys($message);
$key = $keys[0];
if ($key === 'failure' || $key === 'notice') {
$this->__flashMessenger->addMessage(array('level' => $key, 'message' => $message[$key]));
} else {
$this->__flashMessenger->addMessage(array('level' => 'notice', 'message' => $message[$key]));
}
} else {
if (is_string($message) && $message != '') {
$this->__flashMessenger->addMessage(array('level' => 'notice', 'message' => $message));
}
}
}
$this->_logger->debug("redirect to module: {$module} controller: {$controller} action: {$action}");
$this->__redirector->gotoSimple($action, $controller, $module, $params);
$this->__redirector->setExit($exit);
return;
}
示例15: errorAction
public function errorAction()
{
$errors = $this->_getParam('error_handler');
$exception = $errors->exception;
$log = new Zend_Log(new Zend_Log_Writer_Stream('/tmp/applicationException.log'));
$log->debug($exception->getMessage() . "\n" . $exception->getTraceAsString());
if (!$errors || !$errors instanceof ArrayObject) {
$this->view->message = 'You have reached the error page';
return;
}
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
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);
$priority = Zend_Log::NOTICE;
$this->view->message = 'Page not found';
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$priority = Zend_Log::CRIT;
$this->view->message = 'Application error';
break;
}
// Log exception, if logger available
if ($log = $this->getLog()) {
$log->log($this->view->message, $priority, $errors->exception);
$log->log('Request Parameters', $priority, $errors->request->getParams());
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}