本文整理汇总了PHP中Zend_Log::crit方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::crit方法的具体用法?PHP Zend_Log::crit怎么用?PHP Zend_Log::crit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::crit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGeneratedEmail
/**
* @return Zend_Mail
*/
protected function getGeneratedEmail($options = array())
{
$writer = new Zle_Log_Writer_Mail($options);
$log = new Zend_Log($writer);
$log->crit('Foo message');
// cause writer shutdown and log events
unset($log);
$this->assertEquals(1, $this->_transport->getSentNumber(), 'One message should be sent');
return current($this->_transport->getSentEmails());
}
示例2: errorAction
public function errorAction()
{
$errors = $this->_getParam('error_handler');
if (!$errors) {
$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);
$this->view->message = 'Page not found';
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
break;
}
$mail = new Zend_Mail();
$mail->setFrom('errors@fotopracownia.info')
->addTo('raszczynski@gmail.com');
$writer = new Zend_Log_Writer_Mail($mail);
$writer->setSubjectPrependText('Errors from facebook');
$log = new Zend_Log();
$log->addWriter($writer);
$message = "Message: {$errors->exception->getMessage()} \nStack trace: {$errors->exception->getTraceAsString()}";
$log->crit($message);
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
示例3: processAction
protected function processAction()
{
$writer = new Zend_Log_Writer_Stream('php://stdout');
$logger = new Zend_Log($writer);
$settings = Settings::getInstance();
try {
$view = $this->application->getBootstrap()->getResource('view');
$view->setScriptPath(APPLICATION_PATH . '/views/scripts');
$adapter = Zend_Db_Table::getDefaultAdapter();
$stmt = $adapter->query(<<<SQL
SELECT id,
(CASE WHEN awaits_from is null THEN created_at
ELSE awaits_from END) "awaits_from",
customer_considering, closing_time FROM negotiations.negotiation_step WHERE closing_time is null AND created_at > '2013-08-01'::date
SQL
);
//
$toProcess = $stmt->fetchAll();
$logger->info('Found ' . count($toProcess) . ' ongoing negotiations.');
$errs = 0;
$to_exp = 0;
$now = date('Y-m-d', time());
$model = new NegotiationStep();
$adapter->query(<<<SQL
ALTER TABLE negotiations.negotiation_step DISABLE TRIGGER negotiation_step_last_update_refresh
SQL
);
foreach ($toProcess as $nid) {
if ($nid['customer_considering'] == 'true' || $nid['customer_considering'] == 'TRUE' || $nid['customer_considering'] == 't') {
switch ('working') {
case 'working':
$date = @Logic_DateUtils::getDateByWorkingDays(5, $nid['awaits_from']) . ' 23:59:59';
break;
case 'calendar':
$date = date('Y-m-d', strtotime($nid['awaits_from'] . ' +' . 5 . ' days')) . ' 23:59:59';
break;
default:
throw new Exception('Misconfiguration in negotiations.settings table');
}
} else {
switch ('working') {
case 'working':
$date = @Logic_DateUtils::getDateByWorkingDays(5, $nid['awaits_from']) . ' 23:59:59';
break;
case 'calendar':
$date = date('Y-m-d', strtotime($nid['awaits_from'] . ' +' . 5 . ' days')) . ' 23:59:59';
break;
default:
throw new Exception('Misconfiguration in negotiations.settings table');
}
}
$to_exp++;
try {
$model->update(array('closing_time' => $date), 'id = \'' . $nid['id'] . '\'');
} catch (Exception $e) {
$errs++;
}
echo $to_exp . "\t" . $errs . "\n";
}
$adapter->query(<<<SQL
ALTER TABLE negotiations.negotiation_step ENABLE TRIGGER negotiation_step_last_update_refresh
SQL
);
if ($errs == 0) {
$logger->info('Successfuly expired all qualifying negotiations (' . $to_exp . ')');
} else {
$logger->warn('Negotiations qualifying for expiration processed with errors. ' . $errs . '/' . count($to_exp) . ' failed. Check previous log messages for details.');
}
} catch (Exception $e) {
$logger->crit($e->getMessage());
}
$logger->info('Script executed succesfully');
exit(0);
}
示例4: critical
/**
* Prio 2: Critical: critical conditions
*
* @param string $msg
* @param EngineBlock_Log_Message_AdditionalInfo $additionalInfo
* @return void
*/
public function critical($msg, $additionalInfo = null)
{
$this->_setAdditionalEventItems($additionalInfo);
parent::crit($msg);
}
示例5: _handlePost
protected function _handlePost()
{
if (count($_GET) == 1) {
$arrayKeys = array_keys($_GET);
$requestParameters = $this->_decodeRequestParameters($arrayKeys[0]);
} else {
$requestParameters = $this->_getRequestParameters();
}
if ($this->_logger instanceof Zend_Log) {
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' REQUEST ' . print_r($requestParameters, true));
}
$userAgent = $this->_request->getServer('HTTP_USER_AGENT', $requestParameters['deviceType']);
$policyKey = $this->_request->getServer('HTTP_X_MS_POLICYKEY');
if ($this->_logger instanceof Zend_Log) {
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " Agent: {$userAgent} PolicyKey: {$policyKey} ASVersion: {$requestParameters['protocolVersion']} Command: {$requestParameters['command']}");
}
$className = 'Syncope_Command_' . $requestParameters['command'];
if (!class_exists($className)) {
throw new Syncope_Exception_CommandNotFound('unsupported command ' . $requestParameters['command']);
}
// get user device
$device = $this->_getUserDevice($this->_userId, $requestParameters['deviceId'], $requestParameters['deviceType'], $userAgent, $requestParameters['protocolVersion']);
if ($this->_request->getServer('CONTENT_TYPE') == 'application/vnd.ms-sync.wbxml') {
// decode wbxml request
try {
$decoder = new Wbxml_Decoder($this->_body);
$requestBody = $decoder->decode();
if ($this->_logger instanceof Zend_Log) {
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " xml request: " . $requestBody->saveXML());
}
} catch (Wbxml_Exception_UnexpectedEndOfFile $e) {
$requestBody = NULL;
}
} else {
$requestBody = $this->_body;
}
try {
$command = new $className($requestBody, $device, $policyKey);
$command->handle();
if (PHP_SAPI !== 'cli') {
header("MS-Server-ActiveSync: 8.3");
}
$response = $command->getResponse();
} catch (Syncope_Exception_PolicyKeyMissing $sepkm) {
if ($this->_logger instanceof Zend_Log) {
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " X-MS-POLICYKEY missing (" . $_command . ')');
}
header("HTTP/1.1 400 header X-MS-POLICYKEY not found");
return;
} catch (Syncope_Exception_ProvisioningNeeded $sepn) {
if ($this->_logger instanceof Zend_Log) {
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " provisioning needed");
}
header("HTTP/1.1 449 Retry after sending a PROVISION command");
return;
} catch (Exception $e) {
if ($this->_logger instanceof Zend_Log) {
$this->_logger->crit(__METHOD__ . '::' . __LINE__ . " unexpected exception occured: " . get_class($e));
}
if ($this->_logger instanceof Zend_Log) {
$this->_logger->crit(__METHOD__ . '::' . __LINE__ . " exception message: " . $e->getMessage());
}
if ($this->_logger instanceof Zend_Log) {
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " " . $e->getTraceAsString());
}
header("HTTP/1.1 500 Internal server error");
return;
}
if ($response instanceof DOMDocument) {
if ($this->_logger instanceof Zend_Log) {
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " xml response: " . $response->saveXML());
}
$outputStream = fopen("php://temp", 'r+');
$encoder = new Wbxml_Encoder($outputStream, 'UTF-8', 3);
$encoder->encode($response);
header("Content-Type: application/vnd.ms-sync.wbxml");
rewind($outputStream);
fpassthru($outputStream);
}
}
示例6: _runApp
/**
* Run the application, catch the exceptions and log them if a logger
* is available in Zend_Application attacched to the app
*
* @param Zle_Application_Cli_Cli $application application instance
*
* @return void
*/
private static function _runApp(Zle_Application_Cli_Cli $application)
{
/** @var Zend_Application $app */
$app = $application->getApplication();
if ($app->getBootstrap()->hasPluginResource('log')) {
$log = $app->getBootstrap()->getResource('log');
} else {
$log = new Zend_Log(new Zend_Log_Writer_Stream('php://stderr'));
}
try {
// to run the app
$application->run();
} catch (Exception $e) {
$log->crit('Error during execution: ' . $e->getMessage(), $e);
}
}
示例7: crit
public static function crit($message)
{
self::$_logger->crit($message);
}
示例8: fatalError
/**
* Handle fatal errors.
*
* @param Zend_Log $logger
*/
public function fatalError($logger)
{
if (!is_null(error_get_last())) {
$e = error_get_last();
$environment = Zend_Registry::get('configGlobal')->environment;
switch ($environment) {
case 'production':
$message = 'The system has encountered the following error:<br/><h3>';
$message .= htmlspecialchars($e['message'], ENT_QUOTES, 'UTF-8') . '<br/>';
$message .= 'In ' . htmlspecialchars($e['file'], ENT_QUOTES, 'UTF-8') . ', line: ' . htmlspecialchars($e['line'], ENT_QUOTES, 'UTF-8') . '<br/>';
$message .= 'At ' . date('H:i:s Y-m-d') . '</h3><br/>';
$message .= 'Please notify your administrator with this information.<br/>';
if ($e['type'] == E_NOTICE) {
$e['typeText'] = 'E_NOTICE';
} elseif ($e['type'] == E_ERROR) {
$e['typeText'] = 'E_ERROR';
} elseif ($e['type'] == 4) {
$e['typeText'] = '4';
} elseif ($e['type'] == E_WARNING) {
$e['typeText'] = 'E_WARNING';
} elseif ($e['type'] == E_PARSE) {
$e['typeText '] = 'E_PARSE';
} elseif ($e['type'] == E_RECOVERABLE_ERROR) {
$e['typeText '] = 'E_RECOVERABLE_ERROR';
} elseif ($e['type'] == E_COMPILE_ERROR) {
$e['typeText '] = 'E_COMPILE_ERROR';
} else {
return;
}
header('content-type: text/html');
if (count(ob_list_handlers()) > 0) {
ob_clean();
}
echo $message;
$this->_environment = $environment;
break;
default:
$this->_server = $_SERVER;
if ($e['type'] == E_NOTICE) {
$e['typeText'] = 'E_NOTICE';
} elseif ($e['type'] == E_ERROR) {
$e['typeText'] = 'E_ERROR';
} elseif ($e['type'] == 4) {
$e['typeText'] = '4';
} elseif ($e['type'] == E_WARNING) {
$e['typeText'] = 'E_WARNING';
} elseif ($e['type'] == E_PARSE) {
$e['typeText '] = 'E_PARSE';
} elseif ($e['type'] == E_RECOVERABLE_ERROR) {
$e['typeText '] = 'E_RECOVERABLE_ERROR';
} elseif ($e['type'] == E_COMPILE_ERROR) {
$e['typeText '] = 'E_COMPILE_ERROR';
} else {
return;
}
if (count(ob_list_handlers()) > 0) {
ob_clean();
}
$db = Zend_Registry::get('dbAdapter');
$table = $db->listTables();
if (file_exists(LOCAL_CONFIGS_PATH . '/database.local.ini') && empty($table)) {
$fc = Zend_Controller_Front::getInstance();
$webroot = $fc->getBaseUrl();
echo "Midas Server is not installed. <a href='" . $webroot . "/install?reset=true'>Click here to reset Midas Server and go to the installation page.</a>";
return;
}
header('content-type: text/plain');
echo $this->getFatalErrorMessage($e);
}
$logger->crit($this->getFatalErrorMessage($e));
$logger->__destruct();
}
}