本文整理汇总了PHP中Zend_Log::warn方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::warn方法的具体用法?PHP Zend_Log::warn怎么用?PHP Zend_Log::warn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::warn方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
$logger->addPriority('LOGD', 8);
$writer->setPriorityStyle(8, 'LOG');
$logger->addPriority('ERROR', 9);
$writer->setPriorityStyle(9, 'ERROR');
$logger->addPriority('TRACE', 10);
$writer->setPriorityStyle(10, 'TRACE');
$logger->addPriority('EXCEPTION', 11);
$writer->setPriorityStyle(11, 'EXCEPTION');
$logger->addPriority('TABLE', 12);
$writer->setPriorityStyle(12, 'TABLE');
$logger->logd($_SERVER);
$logger->info($_SERVER);
$logger->warn($_SERVER);
$logger->error($_SERVER);
$logger->trace($_SERVER);
try {
throw new Exception('Test Exception');
} catch (Exception $e) {
$logger->exception($e);
}
$logger->table(array('2 SQL queries took 0.06 seconds', array(array('SQL Statement', 'Time', 'Result'), array('SELECT * FROM Foo', '0.02', array('row1', 'row2')), array('SELECT * FROM Bar', '0.04', array('row1', 'row2')))));
}
示例2: send
/**
* Send data
* @param array $data
* @return boolean
*/
public function send(Message $message)
{
$router = $this->_params['router'];
if (!$router) {
$this->_logger->warn('Publish router is not defined: message cannot be sent');
return;
}
//创建channel
$channel = $this->_getChannel();
//创建exchange
$exchange = $this->_getExchange();
if (!$exchange->declareExchange()) {
return false;
}
//创建队列
$this->_getQueue();
$publishParams = ['content_type' => 'text/plain', 'app_id' => 100, 'message_id' => 100, 'delivery_mode' => 2, 'priority' => 9, 'type' => 'system', 'timestamp' => time(), 'reply_to' => 'hacker', 'headers' => ['name' => 'Musikar']];
$publishParams = array_merge($this->_publishParams, $publishParams);
$channel->startTransaction();
//将你的消息通过制定routingKey发送
$data = $message->getData();
foreach ($data as $value) {
$result = $exchange->publish(serialize($value), $router, AMQP_NOPARAM, $publishParams);
}
$channel->commitTransaction();
$this->close();
return $result;
}
示例3: setJsonResponseAsArray
/**
*
* @param Apache_Solr_Response $solrResponse
*/
private function setJsonResponseAsArray($solrResponse)
{
try {
$this->jsonResponse = Zend_Json::decode($solrResponse->getRawResponse());
if (is_null($this->jsonResponse)) {
$this->log->warn("result of decoding solr's json string is null");
}
} catch (Exception $e) {
$this->log->warn("error while decoding solr's json response");
}
}
示例4: send
/**
* Send message
*
* @param Oggetto_Messenger_Model_Message_Interface $message Message
* @return void
*/
public function send(Oggetto_Messenger_Model_Message_Interface $message)
{
if (!$this->_publishRouter) {
$this->_logger->warn('Publish router is not defined: message cannot be sent');
return;
}
if ($queue = $this->_publishRouter->findMessageQueue($message)) {
$this->_declareQueue($queue);
$this->_sendMessage($message, $queue);
} else {
$this->_logger->warn('Destination queue not found for message:');
$this->_logger->warn(print_r($message->getMeta(), true));
}
}
示例5: setFacetFieldsFromConfig
private function setFacetFieldsFromConfig()
{
if (!isset($this->config->searchengine->solr->facets)) {
// no facets are being configured
$this->log->warn("Key searchengine.solr.facets is not present in config. No facets will be displayed.");
return array();
}
$result = array();
$facets = $this->getAvailableFacetsFromConfig();
foreach ($facets as $facet) {
array_push($result, trim($facet));
}
return $result;
}
示例6: 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;
}
示例7: run
/**
* Run scheduling of jobs. All jobs currently in the queue get
* processed and any new jobs get created in the jobs table.
*
* @return void
*/
public function run()
{
$jobs = Opus_Job::getByLabels(array_keys($this->_workers), $this->_limit, Opus_Job::STATE_UNDEFINED);
if (null !== $this->_logger) {
$this->_logger->info('Found ' . count($jobs) . ' job(s)');
}
$runJobs = 0;
foreach ($jobs as $job) {
if (true === $this->consume($job)) {
$runJobs++;
} else {
if (null !== $this->_logger) {
$this->_logger->warn('Job with ID ' . $job->getId() . ' failed.');
}
}
}
if (null !== $this->_logger) {
$this->_logger->info('Processed ' . $runJobs . ' job(s).');
}
}
示例8: attachFulltextToXml
/**
* for each file that is associated to the given document the fulltext and
* path information are attached to the xml representation of the document model
*
* @param DomDocument $modelXml
* @param Opus_File $files
* @param $docId
* @return void
*/
private function attachFulltextToXml($modelXml, $files, $docId)
{
$docXml = $modelXml->getElementsByTagName('Opus_Document')->item(0);
if (is_null($docXml)) {
$this->log->warn('An error occurred while attaching fulltext information to the xml for document with id ' . $docId);
return;
}
// only consider files which are visible in frontdoor
$files = array_filter($files, function ($file) {
return $file->getVisibleInFrontdoor() === '1';
});
if (count($files) == 0) {
$docXml->appendChild($modelXml->createElement('Has_Fulltext', 'false'));
return;
}
$docXml->appendChild($modelXml->createElement('Has_Fulltext', 'true'));
foreach ($files as $file) {
$fulltext = '';
try {
$this->totalFileCount++;
$fulltext = trim(iconv("UTF-8", "UTF-8//IGNORE", $this->getFileContent($file)));
} catch (Opus_SolrSearch_Index_Exception $e) {
$this->errorFileCount++;
$this->log->err('An error occurred while getting fulltext data for document with id ' . $docId . ': ' . $e->getMessage());
}
if ($fulltext != '') {
$element = $modelXml->createElement('Fulltext_Index');
$element->appendChild($modelXml->createCDATASection($fulltext));
$docXml->appendChild($element);
$element = $modelXml->createElement('Fulltext_ID_Success');
$element->appendChild($modelXml->createTextNode($this->getFulltextHash($file)));
$docXml->appendChild($element);
} else {
$element = $modelXml->createElement('Fulltext_ID_Failure');
$element->appendChild($modelXml->createTextNode($this->getFulltextHash($file)));
$docXml->appendChild($element);
}
}
}
示例9: 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);
}
示例10: warn
/**
* Prio 4: Warning: warning conditions
*
* @param string $msg
* @param EngineBlock_Log_Message_AdditionalInfo $additionalInfo
* @return void
*/
public function warn($msg, $additionalInfo = null)
{
$this->_setAdditionalEventItems($additionalInfo);
parent::warn($msg);
}
示例11: _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);
}
}
示例12: _initLogging
/**
* Setup Logging
*
* @throws Exception If logging file couldn't be opened.
* @return void
*
*/
protected function _initLogging()
{
$this->bootstrap('Configuration');
$config = $this->getResource('Configuration');
// Detect if running in CGI environment.
$logFilename = 'opus.log';
if (!array_key_exists('SERVER_PROTOCOL', $_SERVER) and !array_key_exists('REQUEST_METHOD', $_SERVER)) {
$logFilename = "opus-console.log";
}
$logfilePath = $config->workspacePath . '/log/' . $logFilename;
$logfile = @fopen($logfilePath, 'a', false);
if ($logfile === false) {
// TODO use Opus exception
throw new Exception('Failed to open logging file:' . $logfilePath);
}
$GLOBALS['id_string'] = uniqid();
// Write ID string to global variables, so we can identify/match individual runs.
$format = '%timestamp% %priorityName% (%priority%, ID ' . $GLOBALS['id_string'] . '): %message%' . PHP_EOL;
$formatter = new Zend_Log_Formatter_Simple($format);
$writer = new Zend_Log_Writer_Stream($logfile);
$writer->setFormatter($formatter);
$logger = new Zend_Log($writer);
$logLevelName = 'INFO';
$logLevelNotConfigured = false;
if (isset($config->log->level)) {
$logLevelName = strtoupper($config->log->level);
} else {
$logLevelNotConfigured = true;
}
$zendLogRefl = new ReflectionClass('Zend_Log');
$invalidLogLevel = false;
$logLevel = $zendLogRefl->getConstant($logLevelName);
if (empty($logLevel)) {
$logLevel = Zend_Log::INFO;
$invalidLogLevel = true;
}
// filter log output
$priorityFilter = new Zend_Log_Filter_Priority($logLevel);
Zend_Registry::set('LOG_LEVEL', $logLevel);
$logger->addFilter($priorityFilter);
if ($logLevelNotConfigured) {
$logger->warn('Log level not configured, using default \'' . $logLevelName . '\'.');
}
if ($invalidLogLevel) {
$logger->err('Invalid log level \'' . $logLevelName . '\' configured.');
}
Zend_Registry::set('Zend_Log', $logger);
$logger->debug('Logging initialized');
return $logger;
}
示例13: warn
public static function warn($message)
{
self::$_logger->warn($message);
}
示例14: exit
if (count($argv) != 2) {
echo "usage: " . __FILE__ . " logfile.log\n";
exit(-1);
}
echo "\nmigrating classification subjects -- can take a while";
// Initialize logger.
$logfileName = $argv[1];
$logfile = @fopen($logfileName, 'a', false);
$writer = new Zend_Log_Writer_Stream($logfile);
$formatter = new Zend_Log_Formatter_Simple('%timestamp% %priorityName%: %message%' . PHP_EOL);
$writer->setFormatter($formatter);
$logger = new Zend_Log($writer);
// load collections (and check existence)
$mscRole = Opus_CollectionRole::fetchByName('msc');
if (!is_object($mscRole)) {
$logger->warn("MSC collection does not exist. Cannot migrate SubjectMSC.");
}
$ddcRole = Opus_CollectionRole::fetchByName('ddc');
if (!is_object($ddcRole)) {
$logger->warn("DDC collection does not exist. Cannot migrate SubjectDDC.");
}
// create enrichment keys (if neccessary)
createEnrichmentKey('MigrateSubjectMSC');
createEnrichmentKey('MigrateSubjectDDC');
// Iterate over all documents.
$docFinder = new Opus_DocumentFinder();
$changedDocumentIds = array();
foreach ($docFinder->ids() as $docId) {
$doc = null;
try {
$doc = new Opus_Document($docId);