本文整理汇总了PHP中CakeLog::error方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeLog::error方法的具体用法?PHP CakeLog::error怎么用?PHP CakeLog::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeLog
的用法示例。
在下文中一共展示了CakeLog::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runBookProcess
/**
* launches the book build process
* @param int $chaucerBookId
* @return boolean
*/
public function runBookProcess()
{
$bookSource = $this->getBookSourceType();
if (!$bookSource) {
throw new Exception("Book {$this->bookId} not found in chaucer database.");
}
$objProcessor = $this->getBookProcessor($bookSource);
if (is_object($objProcessor)) {
$objProcessor->progressBookId = $this->updateBookId;
$objProcessor->completedState = $this->completedState;
$objProcessor->uploadedFiles = $this->sourceFiles;
try {
return $objProcessor->process();
} catch (Exception $e) {
$msg = trim($e->getMessage());
if (strlen($msg) > 0) {
if (substr($msg, 0, 1) == '[') {
$displayMsg = substr($msg, strpos($msg, ']') + 1);
} else {
$displayMsg = $msg;
}
}
if (is_object($objProcessor->progress)) {
CakeLog::error($e->getMessage());
$objProcessor->processError($displayMsg);
} else {
trigger_error($e->getMessage(), E_USER_ERROR);
}
}
} else {
throw new Exception('[ProcessQueue::runBookProcess] Unknown book source');
}
return false;
}
示例2: execute
/**
* Starts a new background task by passing some data to it with a priority
*
* @param string $taskName name of the task to be executed
* @param mixed $data info to be passed to background task
* @param sting $priority null for normal or either "low" or "high"
* @return boolean success
**/
public static function execute($taskName, $data = null, $priority = null)
{
if (!empty($priority)) {
$priority = strtolower($priority);
if (!in_array($priority, array('low', 'high'))) {
throw new InvalidArgumentException(sprintf('%s is not a valid priority, only accepting low and high', $priority));
}
}
$prefix = Configure::read('Gearman.prefix');
if ($prefix) {
$taskName = $prefix . '_' . $taskName;
}
$data = json_encode($data);
CakeLog::debug(sprintf('Creating background job: %s', $taskName), array('gearman'));
if ($priority == 'low') {
$job = static::client()->doLowBackground($taskName, $data);
}
if ($priority == 'high') {
$job = static::client()->doHighBackground($taskName, $data);
}
if (empty($priority)) {
$job = static::client()->doBackground($taskName, $data);
}
if (static::client()->returnCode() !== GEARMAN_SUCCESS) {
CakeLog::error(sprintf('Could not create background job for task %s and data %s. Got %s (%s)', $taskName, $data, $job, static::client()->error()), array('gearman'));
return false;
}
return true;
}
示例3: saveQuestionnaireBlocksSetting
/**
* Save questionnaire settings
*
* @param array $data received post data
* @return bool True on success, false on failure
* @throws InternalErrorException
*/
public function saveQuestionnaireBlocksSetting($data)
{
$this->loadModels(['BlockRolePermission' => 'Blocks.BlockRolePermission']);
//トランザクションBegin
$this->setDataSource('master');
$dataSource = $this->getDataSource();
$dataSource->begin();
try {
if (!$this->validateQuestionnaireBlocksSetting($data)) {
return false;
}
foreach ($data[$this->BlockRolePermission->alias] as $value) {
if (!$this->BlockRolePermission->validateBlockRolePermissions($value)) {
$this->validationErrors = Hash::merge($this->validationErrors, $this->BlockRolePermission->validationErrors);
return false;
}
}
if (!$this->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
foreach ($data[$this->BlockRolePermission->alias] as $value) {
if (!$this->BlockRolePermission->saveMany($value, ['validate' => false])) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
}
//トランザクションCommit
$dataSource->commit();
} catch (Exception $ex) {
//トランザクションRollback
$dataSource->rollback();
CakeLog::error($ex);
throw $ex;
}
return true;
}
示例4: view
/**
* view
*
* @return void
* @throws Exception
*/
public function view()
{
if (!Current::read('Block.id')) {
$this->autoRender = false;
return;
}
$isAccessed = 'block_key_' . Current::read('Block.key');
//AccessCounterFrameSettingデータ取得
$counterFrameSetting = $this->AccessCounterFrameSetting->getAccessCounterFrameSetting(true);
$this->set('accessCounterFrameSetting', $counterFrameSetting['AccessCounterFrameSetting']);
//AccessCounterデータ取得
$accessCounter = $this->AccessCounter->getAccessCounter(true);
// カウントアップ処理
if (!$this->Session->read($isAccessed)) {
try {
$this->AccessCounter->updateCountUp($accessCounter);
$accessCounter['AccessCounter']['count']++;
// アクセス情報を記録
$this->Session->write($isAccessed, CakeSession::read('Config.userAgent'));
} catch (Exception $ex) {
CakeLog::error($ex);
throw $ex;
}
}
$this->set('accessCounter', $accessCounter['AccessCounter']);
}
示例5: execute
public static function execute($command, $cwd = null, $env = null, $allowSudo = true)
{
$descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
\CakeLog::debug("Executing command: {$command}");
if (!empty($cwd)) {
\CakeLog::debug("--> cwd = {$cwd}");
}
// Execute command
$process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
if (!is_resource($process)) {
\CakeLog::error("Could not execute command: {$command}");
throw new Exception("Could not execute command: {$command}");
}
// close stdin
fclose($pipes[0]);
$stdout = $stderr = $buffer = $errbuf = "";
while (($buffer = fgets($pipes[1], 1024)) != NULL || ($errbuf = fgets($pipes[2], 1024)) != NULL) {
if (!empty($buffer)) {
$stdout .= $buffer;
\CakeLog::debug('--> stdout: ' . trim($buffer));
}
if (!empty($errbuf)) {
$stderr .= $errbuf;
\CakeLog::error('--> stderr: ' . trim($errbuf));
}
}
fclose($pipes[1]);
fclose($pipes[2]);
$exit_code = proc_close($process);
\CakeLog::debug("--> exit_code: {$exit_code}");
unset($pipes[0], $pipes[1], $pipes[2], $pipes);
unset($descriptorspec[0], $descriptorspec[1], $descriptorspec[2], $descriptorspec);
return compact('stdout', 'stderr', 'exit_code', 'command', 'cwd', 'env');
}
示例6: uninstallPlugin
/**
* Uninstall plugin
*
* @param Model $model Model using this behavior
* @param array $data Plugin data
* @return bool True on success
* @throws InternalErrorException
*/
public function uninstallPlugin(Model $model, $data)
{
$model->loadModels(['Plugin' => 'PluginManager.Plugin', 'PluginsRole' => 'PluginManager.PluginsRole', 'PluginsRoom' => 'PluginManager.PluginsRoom']);
//トランザクションBegin
$model->setDataSource('master');
$dataSource = $model->getDataSource();
$dataSource->begin();
if (is_string($data)) {
$key = $data;
} else {
$key = $data[$model->alias]['key'];
}
try {
//Pluginの削除
if (!$model->deleteAll(array($model->alias . '.key' => $key), false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//PluginsRoomの削除
if (!$model->PluginsRoom->deleteAll(array($model->PluginsRoom->alias . '.plugin_key' => $key), false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//PluginsRoleの削除
if (!$model->PluginsRole->deleteAll(array($model->PluginsRole->alias . '.plugin_key' => $key), false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//トランザクションCommit
$dataSource->commit();
} catch (Exception $ex) {
//トランザクションRollback
$dataSource->rollback();
CakeLog::error($ex);
throw $ex;
}
return true;
}
示例7: ping
/**
* PING
*
* @param string|null $url pingのURL(テストで使用する)
* @return mixed fsockopenの結果
*/
public function ping($url = null)
{
//サイトの生死確認
$errno = 0;
$errstr = null;
if (!$url) {
$url = self::NOTIFICATION_PING_URL;
}
CakeLog::info('Execute ping ' . $url);
try {
$resource = fsockopen($url, 80, $errno, $errstr, 3);
} catch (Exception $ex) {
$resource = false;
CakeLog::error($ex);
}
if (!$resource) {
CakeLog::info('Failure ping ' . $url);
$result = false;
} else {
fclose($resource);
$result = true;
CakeLog::info('Success ping ' . $url);
}
return $result;
}
示例8: saveUserAttributesOrder
/**
* Move Order UserAttributes
*
* @param array $data received post data
* @return bool True on success, false on validation errors
* @throws InternalErrorException
*/
public function saveUserAttributesOrder($data)
{
//トランザクションBegin
$this->setDataSource('master');
$dataSource = $this->getDataSource();
$dataSource->begin();
try {
////バリデーション
//$indexes = array_keys($data['LinkOrders']);
//foreach ($indexes as $i) {
// if (! $this->validateLinkOrder($data['LinkOrders'][$i])) {
// return false;
// }
//}
//
////登録処理
//foreach ($indexes as $i) {
// if (! $this->save($data['LinkOrders'][$i], false, false)) {
// throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
// }
//}
//トランザクションCommit
$dataSource->commit();
} catch (Exception $ex) {
//トランザクションRollback
$dataSource->rollback();
CakeLog::error($ex);
throw $ex;
}
return true;
}
示例9: saveBlogFrameSetting
/**
* save blog
*
* @param array $data received post data
* @return mixed On success Model::$data if its not empty or true, false on failure
* @throws InternalErrorException
*/
public function saveBlogFrameSetting($data)
{
$this->loadModels(['BlogFrameSetting' => 'Blogs.BlogFrameSetting']);
//トランザクションBegin
$dataSource = $this->getDataSource();
$dataSource->begin();
try {
//バリデーション
if (!$this->validateBlogFrameSetting($data)) {
$dataSource->rollback();
return false;
}
//登録処理
if (!($resultData = $this->save(null, false))) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//トランザクションCommit
$dataSource->commit();
} catch (Exception $ex) {
//トランザクションRollback
$dataSource->rollback();
CakeLog::error($ex);
throw $ex;
}
return $resultData;
}
示例10: loadAllFixtures
/**
* Load a list of $fixtures into a $source
*
* @param string $source The name of your datasource (e.g. default)
* @param array $fixtures An array of fixtures - same format as in CakeTest $fixtures
* @return void
*/
public function loadAllFixtures($source, $fixtures)
{
$this->_initDb($source);
$this->_loadFixtures($fixtures);
CakeLog::debug('Begin fixture import');
CakeLog::debug('');
$nested = $this->_db->useNestedTransactions;
$this->_db->useNestedTransactions = false;
$this->_db->begin();
foreach ($fixtures as $f) {
CakeLog::debug(sprintf('Working on %s', $f));
if (empty($this->_loaded[$f])) {
CakeLog::notice('-> Can not find it in the loaded array.. weird');
continue;
}
$fixture = $this->_loaded[$f];
CakeLog::debug(sprintf('-> Found fixture: %s', get_class($fixture)));
$this->_setupTable($fixture, $this->_db, true);
CakeLog::debug('-> Created table "OK"');
if ($fixture->insert($this->_db)) {
CakeLog::debug('-> Inserted fixture data "OK"');
} else {
CakeLog::error('-> Inserted fixture data "ERROR"');
}
CakeLog::debug('');
}
$this->_db->commit();
$this->_useNestedTransactions = $nested;
CakeLog::debug('Done!');
}
示例11: lookup
public function lookup($url)
{
$results = $this->http->get($url);
if (!$results->isOk()) {
CakeLog::error("GooglePlayApi::lookup: Error: {$url} {$results->reasonPhrase} {$results->body}");
return false;
}
$results = $this->parseHtml($results->body);
return $results;
}
示例12: rotate
public function rotate()
{
try {
$this->_rotate($this->config);
} catch (Exception $e) {
CakeLog::error('LogRotation::rotate() - ' . $e->getMessage(), 'backend');
return false;
}
return true;
}
示例13: saveTest
public function saveTest()
{
$data['Test'] = $this->request->data;
// CakeLog::error(print_r($data, true));
if ($this->Test->save($data)) {
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('controller' => 'departments', 'action' => 'viewTime', $data['Test']['department_id']));
} else {
$this->Session->setFlash('Unable to add your post.');
CakeLog::error($this->Test->validationErrors);
}
}
示例14: parse
public function parse()
{
libxml_clear_errors();
$xml_string = trim(file_get_contents($this->path));
try {
$this->xml = new SimpleXMLElement($xml_string);
return true;
} catch (Exception $e) {
CakeLog::error("Unable to parse TOC: " . implode(', ', libxml_get_errors()));
return false;
}
}
示例15: create
public function create($db)
{
$ok = parent::create($db);
// Workaround: CakeSchema cannot create FULLTEXT fixtures, so we change the table manually after creation
if ($ok) {
$query = "ALTER TABLE `{$this->table}` ADD FULLTEXT INDEX `data` (`data` ASC)";
try {
$db->rawQuery($query);
$this->created[] = $db->configKeyName;
} catch (Exception $e) {
$msg = __d('cake_dev', 'Fixture creation for "%s" failed "%s"', $this->table, $e->getMessage());
CakeLog::error($msg);
trigger_error($msg, E_USER_WARNING);
return false;
}
return true;
}
return false;
}