本文整理匯總了PHP中CakeLog::debug方法的典型用法代碼示例。如果您正苦於以下問題:PHP CakeLog::debug方法的具體用法?PHP CakeLog::debug怎麽用?PHP CakeLog::debug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CakeLog
的用法示例。
在下文中一共展示了CakeLog::debug方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: call
public static function call($action, $parameters = null)
{
$ch = curl_init(YouniqueAPIURL . $action);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (YOUNIQUE_TESTSERVER) {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
} else {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-YNQ-NOSESSION: true'));
if (!empty($parameters)) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters));
}
$result = curl_exec($ch);
curl_close($ch);
$object = json_decode($result);
if (is_object($object) && (!empty($object->result) || is_array($object->result))) {
return $object->result;
} else {
/**
* Results of exception viewable in log and error page.
* Development only @see younique_api.ctp
*/
if (YOUNIQUE_TESTSERVER) {
CakeLog::debug('API Error Action: ' . $action);
CakeLog::debug(var_export($result, true));
}
throw new YouniqueApiException(array('http_result' => $result, 'http_action' => $action));
}
}
示例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: 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');
}
示例4: 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'));
}
示例5: parse
public function parse(DOMElement $node)
{
$manager = IdmlDeclarationManager::getInstance();
foreach ($node->childNodes as $child) {
if ($child->nodeType != XML_ELEMENT_NODE) {
continue;
}
if ($child->nodeName == $this->groupTemplateName) {
$classname = 'Idml' . $this->groupTemplateName;
// something like 'IdmlParagraphStyleGroup'
$obj = new $classname();
$name = $obj->parse($child);
$manager->addDeclaredStyleGroup($name, $obj);
$this->children[] = $name;
} else {
if ($child->nodeName == $this->styleTemplateName) {
$classname = 'Idml' . $this->styleTemplateName;
// something like 'IdmlParagraphStyle'
$obj = new $classname();
$obj->parse($child);
$name = $obj->idmlKeyValues['Self'];
$manager->addDeclaredStyle($name, $obj);
$this->children[] = $name;
} else {
CakeLog::debug("[IdmlDeclaredStyleGroup::parse] Unhandled tag <{$child->nodeName}>");
}
}
}
return $node->hasAttribute('Self') ? $node->getAttribute('Self') : '';
}
示例6: getPositionCSS
/**
* The getPositionCSS function should return a CSS declaration for the element's top and left.
*/
public function getPositionCSS(IdmlElement $element)
{
$elementClass = get_class($element);
switch ($elementClass) {
case 'IdmlTextFrame':
case 'IdmlRectangle':
case 'IdmlGroup':
case 'IdmlPolygon':
case 'IdmlOval':
if (!isset($element->boundary)) {
CakeLog::debug("[IdmlProduceFixedLayout::getDimensionCSS] Expecting boundary to provide position for " . get_class($element));
return '';
}
if ($element->isEmbedded()) {
// Get the positioning parameters, either from the inline styles or the applied style.
// For now, store them in an array for easier passing to called methods.
$positionParams['xOffset'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->AnchorXoffset', null);
$positionParams['yOffset'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->AnchorYoffset', null);
$positionParams['anchorPosition'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->AnchoredPosition', null);
$positionParams['spineRelative'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->SpineRelative', null);
$positionParams['anchorPoint'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->AnchorPoint', null);
$positionParams['horizAlignment'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->HorizontalAlignment', null);
$positionParams['horizRefPoint'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->HorizontalReferencePoint', null);
$positionParams['vertAlignment'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->VerticalAlignment', null);
$positionParams['vertRefPoint'] = $this->getStyleByKey($element, 'AnchoredObjectSetting->VerticalReferencePoint', null);
// Only cases where 'AnchoredPosition' is 'Anchored' are offset
if ($positionParams['anchorPosition'] != 'Anchored') {
return 'position:relative;';
}
// If no anchor offset is set, set position to relative and exit
if (is_null($positionParams['xOffset']) && is_null($positionParams['yOffset'])) {
return 'position:relative;';
}
// At least one anchor offset is set, so set absolute positioning before determining final offsets
$styles['position'] = 'absolute';
// Adjust offsets based on reference point
list($xOffset, $yOffset) = $this->adjustOffsetsToRefPoint($positionParams, $element);
if (!is_null($xOffset)) {
$styles['left'] = $xOffset . 'px';
}
// For now, we aren't managing 'top'. All test cases given use Baseline orientation, which is problematic in translation.
// if (!is_null($yOffset))
// {
// $styles['top'] = $yOffset . 'px';
// }
$styleAttrib = $this->getStyleString($styles);
return $styleAttrib;
} else {
$position = $this->getElementPosition($element);
// Set element's position, to be used to relatively position embedded elements
$element->setPosition($position);
return sprintf("position:absolute; top:%spx; left:%spx;", $position['top'], $position['left']);
}
default:
return '';
}
}
示例7: request
public function request($endpoint, $action, $data = array())
{
$this->socket = new HttpSocket();
$this->response = $this->socket->post("mpapi.localhost/{$endpoint}/{$action}.json", $data);
CakeLog::debug(print_r($this->socket->request, true));
CakeLog::debug(print_r($this->response, true));
if ($this->response->isOk() && $this->response->body()) {
return json_decode($this->response->body(), true);
} else {
return false;
}
}
示例8: load
/**
* The parse function is the starting point for parsing the Styles.xml file.
*/
public function load($filename)
{
$manager = IdmlDeclarationManager::getInstance();
// Read the /Resources/Styles.xml file into a DOMDocument
if (!file_exists($filename)) {
CakeLog::debug("[IdmlDeclarationParser::load] Filename not found {$filename}");
return false;
}
$doc = new DOMDocument();
if ($doc->load($filename) === false) {
CakeLog::debug("[IdmlDeclarationParser::load] Unable to read {$filename}");
return false;
}
$xpath = new DOMXPath($doc);
// Recursively read each of the style groups and their hierarchy of styles
$nodes = $xpath->query('//idPkg:Styles/RootCharacterStyleGroup');
if ($nodes->length > 0) {
$obj = new IdmlCharacterStyleGroup();
$name = $obj->parse($nodes->item(0));
$manager->addDeclaredStyleGroup($name, $obj);
}
$nodes = $xpath->query('//idPkg:Styles/RootParagraphStyleGroup');
if ($nodes->length > 0) {
$obj = new IdmlParagraphStyleGroup();
$name = $obj->parse($nodes->item(0));
$manager->addDeclaredStyleGroup($name, $obj);
}
$nodes = $xpath->query('//idPkg:Styles/RootObjectStyleGroup');
if ($nodes->length > 0) {
$obj = new IdmlObjectStyleGroup();
$name = $obj->parse($nodes->item(0));
$manager->addDeclaredStyleGroup($name, $obj);
}
$nodes = $xpath->query('//idPkg:Styles/RootTableStyleGroup');
if ($nodes->length > 0) {
$obj = new IdmlTableStyleGroup();
$name = $obj->parse($nodes->item(0));
$manager->addDeclaredStyleGroup($name, $obj);
}
$nodes = $xpath->query('//idPkg:Styles/RootCellStyleGroup');
if ($nodes->length > 0) {
$obj = new IdmlCellStyleGroup();
$name = $obj->parse($nodes->item(0));
$manager->addDeclaredStyleGroup($name, $obj);
}
// Using each style's "BasedOn" property, flatten the hierarchy so that each style has all of it's parent's properties.
$manager->resolveAll();
// Turn all properties which had duplicate names into an arrays
foreach ($manager->declaredStyles as $styleName => $declaredStyle) {
self::arrayifyDupes($styleName, $declaredStyle);
}
}
示例9: authenticate
/**
* Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields`
* to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if
* there is no post data, either username or password is missing, or if the scope conditions have not been met.
*
* @param CakeRequest $request The request that contains login information.
* @param CakeResponse $response Unused response object.
* @return mixed False on login failure. An array of User data on success.
*/
public function authenticate(CakeRequest $request, CakeResponse $response)
{
CakeLog::debug('ldap authenticate()');
$userModel = $this->settings['userModel'];
list(, $model) = pluginSplit($userModel);
$fields = $this->settings['fields'];
if (!$this->_checkFields($request, $model, $fields)) {
return false;
}
$con = ldap_connect('127.0.0.1');
$search = ldap_search($con, 'dc=netcommons,dc=local', 'cn=user1');
$result = ldap_get_entries($con, $search);
CakeLog::debug('ldap search: ' . var_export($result, true));
return false;
}
示例10: source
/**
* Load image
*
* @param string $path Path to image relative to webroot
* @param boolean $absolute Path is absolute server path
* @return object $this
*/
public function source($path = '', $absolute = false)
{
$this->sizes = false;
$this->serverPath = false;
$this->_cacheServerPath = false;
if (!$absolute) {
$this->sourceDir = dirname($path);
$path = ROOT . DS . APP_DIR . DS . 'Plugin' . DS . 'Paszport' . DS . WEBROOT_DIR . DS . $path;
}
CakeLog::debug($path);
if ($this->sizes = @getimagesize($path)) {
$this->serverPath = $path;
}
return $this;
}
示例11: initWorkingDir
/**
* Initialize the working directory and ensure it exists
* @return string Path to working directory
*/
public function initWorkingDir()
{
// Check if working directory is already initialized
if (is_dir($this->workingDir)) {
return $this->workingDir;
}
// Get temp target directory
$tmpDir = Configure::read('Chaucer.instanceName') . '/' . $this->bookId;
$targetDir = Folder::addPathElement($this->FileManager->getTmpPath(), $tmpDir);
// Create and return dir
if (!$this->FileManager->createDir($targetDir)) {
throw new Exception('Unable to create working directory: ' . $targetDir);
}
CakeLog::debug('[CommonProcessor::initWorkingDir] working dir: ' . $targetDir);
return $targetDir;
}
示例12: search
/**
* タグ補完用検索
*
* @return void
*/
public function search()
{
$keyword = $this->_getNamed('keyword', '');
$modelName = $this->_getNamed('target', '');
if (empty($keyword) || empty($modelName)) {
return;
}
$blockId = Current::read('Block.id');
$conditions = array('name LIKE' => '%' . $keyword . '%', 'block_id' => $blockId, 'model' => $modelName);
$tags = $this->Tag->find('all', array('conditions' => $conditions));
$results = array();
foreach ($tags as $tag) {
$results[] = $tag['Tag']['name'];
}
CakeLog::debug(serialize($results));
$this->set('results', $results);
$this->set('_serialize', ['results']);
}
示例13: accept
/**
* Accept visitor.
*
* @param IdmlVisitor $visitor
*/
public function accept(IdmlVisitor $visitor, $depth = 0)
{
switch ($this->changeType) {
case 'DeletedText':
return;
case 'InsertedText':
case 'MovedText':
$visitor->visitChange($this, $depth);
foreach ($this->childrenElements as $child) {
$child->accept($visitor, $depth + 1);
}
$visitor->visitChangeEnd($this, $depth);
return;
case 'undefined':
default:
CakeLog::debug("[IdmlChange::accept] Unexpected changeType '" . $this->changeType . "'");
return;
}
}
示例14: getPositionCSS
/**
* The getPositionCSS function should return a CSS declaration for the element's top and left.
* @param IdmlElement $element
* @return string - containing style attributes (may be empty)
*/
public function getPositionCSS(IdmlElement $element)
{
$page = $this->getPage($element);
if (is_null($page)) {
throw new MissingComponentException('No page was found for ' . get_class($element) . '; UID ' . $element->UID);
}
$elementClass = get_class($element);
switch ($elementClass) {
case 'IdmlTextFrame':
case 'IdmlRectangle':
case 'IdmlGroup':
case 'IdmlPolygon':
case 'IdmlOval':
case 'IdmlGraphicLine':
if (!isset($element->boundary)) {
CakeLog::debug("[IdmlProduceFixedLayout::getDimensionCSS] Expecting boundary to provide position for " . get_class($element));
return '';
}
if ($element->isEmbedded()) {
// Get the positioning parameters
$positionParams = $this->getPositionParams($element, $page);
$vertRefPoint = $positionParams['vertRefPoint'];
// If there are values for IDML's AnchoredPosition property other than 'Anchored' and 'InlinePosition' we don't support them
if ($positionParams['anchorPosition'] != 'Anchored' && $positionParams['anchorPosition'] != 'InlinePosition') {
return 'position:relative;';
}
// If no anchor offset is set, set position to relative and exit
if (is_null($positionParams['xOffset']) && is_null($positionParams['yOffset'])) {
return 'position:relative;';
}
// Adjust offsets based on reference point
$this->setRelativeOffsets($element, $positionParams, $page);
list($left, $top) = $this->adjustOffsetsToRefPoint($element);
} else {
$vertRefPoint = null;
list($left, $top) = $this->getElementPosition($element, $page);
}
return $this->getStyleString($element, $left, $top, $vertRefPoint);
default:
return '';
}
}
示例15: 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;
}