本文整理汇总了PHP中CakeLog::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeLog::warning方法的具体用法?PHP CakeLog::warning怎么用?PHP CakeLog::warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeLog
的用法示例。
在下文中一共展示了CakeLog::warning方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
try {
$this->_loadFixtures($fixtures);
} catch (Exception $e) {
CakeLog::error('-> ' . $e->getMessage(), array('fixturize'));
}
CakeLog::debug('Begin fixture import', array('fixturize'));
$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::warning('-> Cannot find it in the loaded array', array('fixturize'));
continue;
}
$fixture = $this->_loaded[$f];
CakeLog::debug(sprintf('-> Found fixture: %s', get_class($fixture)), array('fixturize'));
$this->_setupTable($fixture, $this->_db, true);
CakeLog::debug('-> Created table "OK"', array('fixture'));
if ($fixture->insert($this->_db)) {
CakeLog::debug('-> Inserted fixture data "OK"', array('fixturize'));
} else {
CakeLog::error('-> Inserted fixture data "ERROR"', array('fixturize'));
}
}
$this->_db->commit();
$this->_useNestedTransactions = $nested;
CakeLog::debug('Done!', array('fixturize'));
}
示例2: setup
/**
* setup
*
* @param Model $model
* @param array $config
*/
public function setup(Model $model, $config = array())
{
// catch and adjust old $config parameter names that would have been used rarely and were
// confusingly named:-
// - the "check_cache" parameter has been renamed to "cache_config_name_check"
// - the "default_cache" parameter has been renamed to "cache_config_name_default"
if (isset($config['check_cache'])) {
$config['cache_config_name_check'] = $config['check_cache'];
unset($config['check_cache']);
CakeLog::warning('Use of deprecated Autocache config parameter detected', 'check_cache');
}
if (isset($config['default_cache'])) {
$config['cache_config_name_default'] = $config['default_cache'];
unset($config['default_cache']);
CakeLog::warning('Use of deprecated Autocache config parameter detected', 'default_cache');
}
// > cache_config_name_check - determines if we bother checking if the supplied
// cache configuration name is valid - prevents the developer thinking they are
// caching when they are not - will throw a cache expection if fails this check
//
// > cache_config_name_default - is the default cache name, which by default is
// the string "default" - confused? You just need to make sure you have an
// appropriate Cache::config('default',array(...)) in your bootstrap.php
// or core.php
//
// > dummy_datasource - name of the dummy data source in the database.php file
// should look something like this:-
// public $autocache = array('datasource' => 'AutocacheSource');
$this->runtime = array_merge(array('cache_config_name_check' => Configure::read('debug') > 0 ? true : false, 'cache_config_name_default' => 'default', 'dummy_datasource' => 'autocache'), (array) $config);
}
示例3: getFontCssRules
private function getFontCssRules()
{
if (is_null($this->fontCssRules)) {
$this->fontCssRules = array();
$cssAssets = $this->epub->EpubSpine->getAssetsByType('text/css');
foreach ($cssAssets as $css) {
try {
$cssContent = $this->epub->getPageContent($css->relativePath);
$cssParser = new CSSParser($cssContent);
$objCss = $cssParser->parse();
$this->fonts = array();
foreach ($objCss->getAllRuleSets() as $cssRuleSet) {
$font = array();
if (is_a($cssRuleSet, 'CSSAtRule')) {
$selectorName = $cssRuleSet->getType();
if ($selectorName == 'font-face') {
foreach ($cssRuleSet->getRules() as $cssRule) {
$value = (string) $cssRule->getValue();
if (substr($value, 0, 1) == '"') {
$value = substr($value, 1, -1);
}
$font[$cssRule->getRule()] = $value;
}
$this->fontCssRules[] = $font;
}
}
}
unset($objCss);
unset($cssParser);
} catch (Exception $e) {
CakeLog::warning('[EpubProcessor::getFontCssRules] Error ' . $e->getMessage() . ' when parsing ' . $css->relativePath);
}
}
}
return $this->fontCssRules;
}
示例4: _findView
protected function _findView($state, $query, $results = array())
{
if ($state == 'before') {
if (empty($query['package_id'])) {
throw new InvalidArgumentException(__('Invalid package'));
}
$query['conditions'] = array("{$this->alias}.{$this->primaryKey}" => $query['package_id']);
$query['contain'] = array('Maintainer' => array('name', 'username'));
$query['limit'] = 1;
if (!empty($query['fields'])) {
$query['fields'] = array_merge($this->getDataSource()->fields($this, null, $query['fields']), $this->Category->getDataSource()->fields($this->Category));
} else {
$query['fields'] = array_merge($this->getDataSource()->fields($this), $this->Category->getDataSource()->fields($this->Category));
}
$this->unbindModel(array('belongsTo' => array('Categories.Category')));
$query['joins'] = array(array('alias' => 'Category', 'table' => 'categories', 'type' => 'LEFT', 'conditions' => array('`Category`.`id` = `Package`.`category_id`')));
// Join additional records if necessary
if ($query['user_id']) {
if (!empty($query['fields'])) {
$query['fields'] = array_merge($this->getDataSource()->fields($this, null, $query['fields']), $this->Rating->getDataSource()->fields($this->Rating), $this->Favorite->getDataSource()->fields($this->Favorite));
} else {
$query['fields'] = array_merge($this->getDataSource()->fields($this), $this->Rating->getDataSource()->fields($this->Rating), $this->Favorite->getDataSource()->fields($this->Favorite));
}
$this->unbindModel(array('hasMany' => array('Ratings.Rating', 'Favorites.Favorite')));
$query['joins'][] = array('alias' => 'Favorite', 'table' => 'favorites', 'type' => 'LEFT', 'conditions' => array('`Favorite`.`foreign_key` = `Package`.`id`', 'Favorite.model' => 'Package', 'Favorite.type' => 'bookmark', 'Favorite.user_id' => $query['user_id']));
$query['joins'][] = array('alias' => 'Rating', 'table' => 'ratings', 'type' => 'LEFT', 'conditions' => array('`Rating`.`foreign_key` = `Package`.`id`', 'Rating.model' => 'Package', 'Rating.user_id' => $query['user_id']));
}
return $query;
}
if (empty($results[0])) {
throw new NotFoundException(__('Invalid package'));
}
if (empty($results[0]['Maintainer'])) {
throw new NotFoundException(__('Invalid maintainer'));
}
if (empty($results[0]['Favorite']['id'])) {
$results[0]['Favorite'] = false;
}
if (empty($results[0]['Rating']['id'])) {
$results[0]['Rating'] = false;
}
if ($this->shouldForceUpdate($results[0][$this->alias]['modified'])) {
try {
$this->enqueue('UpdatePackageJob', array($results[0][$this->alias][$this->primaryKey]));
} catch (Exception $e) {
CakeLog::warning('Package::find(\'view\')' . $e->getMessage());
}
}
DebugTimer::start('app.Package::rss', __d('app', 'Package::rss()'));
list($results[0]['Rss'], $results[0]['Cache']) = $this->rss($results[0]);
DebugTimer::stop('app.Package::rss');
return $results[0];
}
示例5: sendBatch
/**
* Stores multiple messages in the queue so it an external client can work upon them.
* For performance reasons, it is better to create jobs in batches instead of one a time
* if you plan to create several jobs in the same process or request.
*
* @param string $taskName a task name as defined in the configure key SQS.queues
* @param array $payloads list of payload data to associate to the new queued message
* for each entry in the array a new message in the queue will be created
* @return array list of messages that failed to be sent or false if an exception was caught
**/
public function sendBatch($taskName, array $payloads)
{
$url = $this->queueUrl($taskName);
try {
CakeLog::debug(sprintf('Creating %d messages in queue: %s', count($payloads), $taskName), array('sqs'));
$result = $this->client()->sendMessageBatch(array('QueueUrl' => $url, 'Entries' => array_map(function ($e) use(&$i) {
return array('Id' => 'a' . $i++, 'MessageBody' => json_encode($e));
}, $payloads)));
$failed = array();
foreach ((array) $result->get('Failed') as $f) {
$failed[(int) substr($f['Id'], 1)] = $f['Message'];
}
if (!empty($failed)) {
CakeLog::warning(sprintf('Failed sending %d messages for queue: %s', count($failed), $taskName), array('sqs'));
}
return $failed;
} catch (Exception $e) {
$this->_handleException($e);
}
return false;
}
示例6: testConvenienceMethods
/**
* test convenience methods
*
* @return void
*/
public function testConvenienceMethods()
{
$this->_deleteLogs();
CakeLog::config('debug', array('engine' => 'File', 'types' => array('notice', 'info', 'debug'), 'file' => 'debug'));
CakeLog::config('error', array('engine' => 'File', 'types' => array('emergency', 'alert', 'critical', 'error', 'warning'), 'file' => 'error'));
$testMessage = 'emergency message';
CakeLog::emergency($testMessage);
$contents = file_get_contents(LOGS . 'error.log');
$this->assertRegExp('/(Emergency|Critical): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'debug.log'));
$this->_deleteLogs();
$testMessage = 'alert message';
CakeLog::alert($testMessage);
$contents = file_get_contents(LOGS . 'error.log');
$this->assertRegExp('/(Alert|Critical): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'debug.log'));
$this->_deleteLogs();
$testMessage = 'critical message';
CakeLog::critical($testMessage);
$contents = file_get_contents(LOGS . 'error.log');
$this->assertContains('Critical: ' . $testMessage, $contents);
$this->assertFalse(file_exists(LOGS . 'debug.log'));
$this->_deleteLogs();
$testMessage = 'error message';
CakeLog::error($testMessage);
$contents = file_get_contents(LOGS . 'error.log');
$this->assertContains('Error: ' . $testMessage, $contents);
$this->assertFalse(file_exists(LOGS . 'debug.log'));
$this->_deleteLogs();
$testMessage = 'warning message';
CakeLog::warning($testMessage);
$contents = file_get_contents(LOGS . 'error.log');
$this->assertContains('Warning: ' . $testMessage, $contents);
$this->assertFalse(file_exists(LOGS . 'debug.log'));
$this->_deleteLogs();
$testMessage = 'notice message';
CakeLog::notice($testMessage);
$contents = file_get_contents(LOGS . 'debug.log');
$this->assertRegExp('/(Notice|Debug): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'error.log'));
$this->_deleteLogs();
$testMessage = 'info message';
CakeLog::info($testMessage);
$contents = file_get_contents(LOGS . 'debug.log');
$this->assertRegExp('/(Info|Debug): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'error.log'));
$this->_deleteLogs();
$testMessage = 'debug message';
CakeLog::debug($testMessage);
$contents = file_get_contents(LOGS . 'debug.log');
$this->assertContains('Debug: ' . $testMessage, $contents);
$this->assertFalse(file_exists(LOGS . 'error.log'));
$this->_deleteLogs();
}
示例7: _authorizeByContent
/**
* Checks authorization by content
*
* @throws CakeException
*/
protected function _authorizeByContent($user, CakeRequest $request, $id)
{
if (!isset($this->settings['actionMap'][$request->params['action']])) {
throw new CakeException(__d('croogo', '_authorizeByContent() - Access of un-mapped action "%1$s" in controller "%2$s"', $request->action, $request->controller));
}
list($plugin, $userModel) = pluginSplit($this->settings['userModel']);
$acoNode = array('model' => $this->_Controller->modelClass, 'foreign_key' => $id);
$alias = sprintf('%s.%s', $acoNode['model'], $acoNode['foreign_key']);
$action = $this->settings['actionMap'][$request->params['action']];
$cacheName = 'permissions_content_' . strval($user['id']);
if (($permissions = Cache::read($cacheName, 'permissions')) === false) {
$permissions = array();
Cache::write($cacheName, $permissions, 'permissions');
}
if (!isset($permissions[$alias][$action])) {
$Acl = $this->_Collection->load('Acl');
try {
$allowed = $Acl->check(array($userModel => $user), $acoNode, $action);
} catch (Exception $e) {
CakeLog::warning('authorizeByContent: ' . $e->getMessage());
$allowed = false;
}
$permissions[$alias][$action] = $allowed;
Cache::write($cacheName, $permissions, 'permissions');
$hit = false;
} else {
$allowed = $permissions[$alias][$action];
$hit = true;
}
if (Configure::read('debug')) {
$status = $allowed ? ' allowed.' : ' denied.';
$cached = $hit ? ' (cache hit)' : ' (cache miss)';
CakeLog::write(LOG_ERR, $user['username'] . ' - ' . $action . '/' . $id . $status . $cached);
}
return $allowed;
}
示例8: cropImage
protected function cropImage($idmlImage, $idmlRectangle, $s3File)
{
$ffi = $idmlRectangle->frameFittingOption;
if ($ffi->hasCroppingInstructions()) {
if (!$this->FileManager->exists($s3File)) {
CakeLog::warning('[IdmlResourceManager::cropImage] Source file ' . $s3File . ' does not exist.');
return false;
}
// InDesign uses 72ppi as its base units for IDML
// convert the cropping instruction units to image pixel units
$leftCrop = $ffi->leftCrop * ($idmlImage->ppiX / 72);
$rightCrop = $ffi->rightCrop * ($idmlImage->ppiX / 72);
$topCrop = $ffi->topCrop * ($idmlImage->ppiY / 72);
$bottomCrop = $ffi->bottomCrop * ($idmlImage->ppiY / 72);
// convert the image dimensions from InDesign units to real pixels
$originalImageWidth = $idmlImage->width * ($idmlImage->ppiX / 72);
$originalImageHeight = $idmlImage->height * ($idmlImage->ppiY / 72);
$widthOfCrop = $originalImageWidth - ($rightCrop + $leftCrop);
$heightOfCrop = $originalImageHeight - ($topCrop + $bottomCrop);
// download from S3 to local computer
$tmp = $this->FileManager->getTmpPath();
$basename = pathinfo($s3File, PATHINFO_BASENAME);
$localFile = $tmp . DS . $basename;
$this->FileManager->copy($s3File, $localFile);
$result = true;
// Crop
$imagick = new Imagick($localFile);
if ($imagick) {
try {
$imagick->cropImage($widthOfCrop, $heightOfCrop, $leftCrop, $topCrop);
$imagick->writeImage();
} catch (Exception $e) {
CakeLog::warning('[IdmlResourceManager::cropImage] Failed to crop ' . $localFile);
$result = false;
}
$imagick->clear();
$imagick->destroy();
}
// upload from local computer to S3
$this->FileManager->copy($localFile, $s3File);
$this->processor->patchSourceAssetList($localFile, $localFile);
return $result;
}
}
示例9: warning
public function warning($message, array $context = array())
{
CakeLog::warning($message, $context);
}
示例10: importSourceAssets
protected function importSourceAssets()
{
if (is_array($this->sourceAssets) && count($this->sourceAssets) > 0) {
foreach ($this->sourceAssets as $localFile => $sourceFileName) {
$ext = pathinfo($sourceFileName, PATHINFO_EXTENSION);
CakeLog::debug('[ImportProcessor::importSourceAssets] processing asset ' . $sourceFileName);
if (in_array($ext, self::$supportedImageTypes)) {
CakeLog::debug('[ImportProcessor::importSourceAssets] Adding image file ' . $localFile . ' to book');
$this->addImageAssetToBook($localFile, 'images/');
} elseif (in_array($ext, self::$supportedFontTypes)) {
CakeLog::debug('[ImportProcessor::importSourceAssets] Adding font file ' . $localFile . ' to book');
$this->addFontToBook($localFile);
} elseif (in_array($ext, self::$supportedAudioTypes)) {
CakeLog::debug('[ImportProcessor::importSourceAssets] Adding audio file ' . $localFile . ' to book');
$this->addAudioAssetToBook($localFile, 'audio/');
} elseif (in_array($ext, self::$supportedVideoTypes)) {
CakeLog::debug('[ImportProcessor::importSourceAssets] Adding video file ' . $localFile . ' to book');
$this->addVideoAssetToBook($localFile, 'video/');
} else {
CakeLog::warning('[ImportProcessor::importSourceAssets] Skipping file' . $sourceFileName . ': unknown file type');
}
$this->progress->incrementStep();
}
}
}
示例11: warning
public function warning($message)
{
CakeLog::warning($message, $this->scope);
}
示例12: _rotate
protected function _rotate($config)
{
// do rotation
$path = $config['path'];
for ($i = $config['keep']; $i >= 0; $i--) {
switch (true) {
case $i == $config['keep']:
$SrcFile = $this->_getFile($path, $i);
if (!$SrcFile->exists()) {
continue;
}
// send report mail
if ($config['email_to']) {
try {
//TODO use dependency injection
//TODO use backend-wide email report settings
$email = new CakeEmail(array('transport' => 'Mail', 'from' => 'report@' . gethostname(), 'to' => $config['email_to'], 'subject' => 'Log report', 'emailFormat' => 'text', 'template' => false, 'layout' => false));
$email->addAttachments($SrcFile->path);
$email->send('Log file attached');
} catch (Exception $e) {
CakeLog::warning('LogRotation::rotate() - ' . $e->getMessage(), 'backend');
}
}
break;
case $i > 0:
$SrcFile = $this->_getFile($path, $i);
if (!$SrcFile->exists()) {
continue;
}
if (!$config['rotate_empty'] && $SrcFile->size() < 1) {
#if (!$SrcFile->delete())
# $this->log[] = "Failed to delete file";
continue;
}
$NewFile = $this->_getFile($path, $i + 1, true);
if (!$NewFile->write($SrcFile->read())) {
throw new Exception("Failed to copy log {$path}.'.'.{$i}");
}
if ($i == 1 && !$config['compress'] && $config['compress_delay']) {
$this->_compress($NewFile);
}
break;
case $i == 0:
$SrcFile = $this->_getFile($path);
if (!$config['rotate_empty'] && $SrcFile->size() < 1) {
continue;
}
$NewFile = $this->_getFile($path, $i + 1, true);
if (!$NewFile->write($SrcFile->read())) {
throw new Exception("Failed to copy log {$path}");
}
if ($config['compress']) {
$this->_compress($NewFile);
}
if (!$SrcFile->write("")) {
throw new Exception("Failed to create empty log {$path}");
}
break;
default:
throw new Exception("Fatal Error");
break;
}
}
}
示例13: createImageAssets
/**
* Create image assets.
*/
private function createImageAssets()
{
// Get image directory
$imageDir = Folder::addPathElement($this->workingDir, 'images');
if (is_dir($imageDir)) {
// Get all image files
$imageFiles = $this->FileManager->getAllFiles($imageDir);
// Check if there are any images
if (count($imageFiles) > 0) {
// Adjust progress
$this->progress->adjustMaxSteps(count($imageFiles), TRUE);
// Loop through image files
foreach ($imageFiles as $imagePath) {
// Get file image name
$imagePathInfo = pathinfo($imagePath);
$imageFilename = $imagePathInfo['basename'];
// Check if image exists
if (file_exists($imagePath)) {
// Path to unlink
$imagePathUnlink = $imagePath;
// Import image files
$this->addImageAssetToBook($imagePath, 'images/');
// Remove image files
unlink($imagePathUnlink);
} else {
CakeLog::warning("[WordProcessor::importImages] File {$imageFilename} not found");
}
// Update step
$this->progress->incrementStep();
}
}
}
}
示例14: _extractWithZipCommand
/**
* ZIPコマンドを使った解凍
*
* @param string $path zipファイルパス
* @return bool
*/
protected function _extractWithZipCommand($path)
{
// コマンドで解凍
$cmd = sprintf('unzip -P %s %s -d %s', $this->_password, $this->_zipPath, $path);
exec($cmd, $output, $returnVar);
if ($returnVar > 0) {
// エラー
CakeLog::warning('Unzip Error:output=' . json_encode($output) . ', return_var=' . $returnVar);
return false;
}
return true;
}