本文整理汇总了PHP中phlog函数的典型用法代码示例。如果您正苦于以下问题:PHP phlog函数的具体用法?PHP phlog怎么用?PHP phlog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phlog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleException
public function handleException(Exception $ex)
{
// Always log the unhandled exception.
phlog($ex);
$class = phutil_escape_html(get_class($ex));
$message = phutil_escape_html($ex->getMessage());
if (PhabricatorEnv::getEnvConfig('phabricator.show-stack-traces')) {
$trace = $this->renderStackTrace($ex->getTrace());
} else {
$trace = null;
}
$content = '<div class="aphront-unhandled-exception">' . '<div class="exception-message">' . $message . '</div>' . $trace . '</div>';
$user = $this->getRequest()->getUser();
if (!$user) {
// If we hit an exception very early, we won't have a user.
$user = new PhabricatorUser();
}
$dialog = new AphrontDialogView();
$dialog->setTitle('Unhandled Exception ("' . $class . '")')->setClass('aphront-exception-dialog')->setUser($user)->appendChild($content);
if ($this->getRequest()->isAjax()) {
$dialog->addCancelButton('/', 'Close');
}
$response = new AphrontDialogResponse();
$response->setDialog($dialog);
return $response;
}
示例2: processRequest
public function processRequest()
{
// No CSRF for SendGrid.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$request = $this->getRequest();
$user = $request->getUser();
$raw_headers = $request->getStr('headers');
$raw_headers = explode("\n", rtrim($raw_headers));
$raw_dict = array();
foreach (array_filter($raw_headers) as $header) {
list($name, $value) = explode(':', $header, 2);
$raw_dict[$name] = ltrim($value);
}
$headers = array('to' => $request->getStr('to'), 'from' => $request->getStr('from'), 'subject' => $request->getStr('subject')) + $raw_dict;
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders($headers);
$received->setBodies(array('text' => $request->getStr('text'), 'html' => $request->getStr('from')));
$file_phids = array();
foreach ($_FILES as $file_raw) {
try {
$file = PhabricatorFile::newFromPHPUpload($file_raw, array('authorPHID' => $user->getPHID()));
$file_phids[] = $file->getPHID();
} catch (Exception $ex) {
phlog($ex);
}
}
$received->setAttachments($file_phids);
$received->save();
$received->processReceivedMail();
$response = new AphrontWebpageResponse();
$response->setContent("Got it! Thanks, SendGrid!\n");
return $response;
}
示例3: doWork
protected function doWork()
{
$lock = $this->acquireTaskLock();
$task = $this->loadTask();
$status = $task->getStatus();
switch ($task->getStatus()) {
case PhabricatorWorkerBulkTask::STATUS_WAITING:
// This is what we expect.
break;
default:
throw new PhabricatorWorkerPermanentFailureException(pht('Found unexpected task status ("%s").', $status));
}
$task->setStatus(PhabricatorWorkerBulkTask::STATUS_RUNNING)->save();
$lock->unlock();
$job = $this->loadJob();
$actor = $this->loadActor($job);
try {
$job->runTask($actor, $task);
$status = PhabricatorWorkerBulkTask::STATUS_DONE;
} catch (Exception $ex) {
phlog($ex);
$status = PhabricatorWorkerBulkTask::STATUS_FAIL;
}
$task->setStatus($status)->save();
$this->updateJob($job);
}
示例4: assertParserResult
private function assertParserResult(array $expect, $input, $file)
{
list($x, $y) = PhutilSocketChannel::newChannelPair();
$xp = new DiffusionMercurialWireClientSSHProtocolChannel($x);
$y->write($input);
$y->flush();
$y->closeWriteChannel();
$messages = array();
for ($ii = 0; $ii < count($expect); $ii++) {
try {
$messages[] = $xp->waitForMessage();
} catch (Exception $ex) {
// This is probably the parser not producing as many messages as
// we expect. Log the exception, but continue to the assertion below
// since that will often be easier to diagnose.
phlog($ex);
break;
}
}
$this->assertEqual($expect, $messages, $file);
// Now, make sure the channel doesn't have *more* messages than we expect.
// Specifically, it should throw when we try to read another message.
$caught = null;
try {
$xp->waitForMessage();
} catch (Exception $ex) {
$caught = $ex;
}
$this->assertTrue($caught instanceof Exception, pht("No extra messages for '%s'.", $file));
}
示例5: getKeys
public function getKeys(array $keys)
{
$results = array();
if ($keys) {
$map = $this->digestKeys($keys);
$rows = queryfx_all($this->establishConnection('r'), 'SELECT * FROM %T WHERE cacheKeyHash IN (%Ls)', $this->getTableName(), $map);
$rows = ipull($rows, null, 'cacheKey');
foreach ($keys as $key) {
if (empty($rows[$key])) {
continue;
}
$row = $rows[$key];
if ($row['cacheExpires'] && $row['cacheExpires'] < time()) {
continue;
}
try {
$results[$key] = $this->didReadValue($row['cacheFormat'], $row['cacheData']);
} catch (Exception $ex) {
// Treat this as a cache miss.
phlog($ex);
}
}
}
return $results;
}
示例6: addRemarkupSection
public function addRemarkupSection($header, $text)
{
try {
$engine = PhabricatorMarkupEngine::newMarkupEngine(array());
$engine->setConfig('viewer', $this->getViewer());
$engine->setMode(PhutilRemarkupEngine::MODE_TEXT);
$styled_text = $engine->markupText($text);
$this->addPlaintextSection($header, $styled_text);
} catch (Exception $ex) {
phlog($ex);
$this->addTextSection($header, $text);
}
try {
$mail_engine = PhabricatorMarkupEngine::newMarkupEngine(array());
$mail_engine->setConfig('viewer', $this->getViewer());
$mail_engine->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL);
$mail_engine->setConfig('uri.base', PhabricatorEnv::getProductionURI('/'));
$html = $mail_engine->markupText($text);
$this->addHTMLSection($header, $html);
} catch (Exception $ex) {
phlog($ex);
$this->addHTMLSection($header, $text);
}
return $this;
}
示例7: destroyObject
public function destroyObject(PhabricatorDestructionEngine $engine, $object)
{
$src_phid = $object->getPHID();
try {
$edges = id(new PhabricatorEdgeQuery())->withSourcePHIDs(array($src_phid))->execute();
} catch (Exception $ex) {
// This is (presumably) a "no edges for this PHID type" exception.
return;
}
$editor = new PhabricatorEdgeEditor();
foreach ($edges as $type => $type_edges) {
foreach ($type_edges as $src => $src_edges) {
foreach ($src_edges as $dst => $edge) {
try {
$editor->removeEdge($edge['src'], $edge['type'], $edge['dst']);
} catch (Exception $ex) {
// We can run into an exception while removing the edge if the
// edge type no longer exists. This prevents us from figuring out
// if there's an inverse type. Just ignore any errors here and
// continue, since the best we can do is clean up all the edges
// we still have information about. See T11201.
phlog($ex);
}
}
}
}
$editor->save();
}
示例8: handleRequest
public function handleRequest(AphrontRequest $request)
{
// No CSRF for Mailgun.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
if (!$this->verifyMessage()) {
throw new Exception(pht('Mail signature is not valid. Check your Mailgun API key.'));
}
$user = $request->getUser();
$raw_headers = $request->getStr('headers');
$raw_headers = explode("\n", rtrim($raw_headers));
$raw_dict = array();
foreach (array_filter($raw_headers) as $header) {
list($name, $value) = explode(':', $header, 2);
$raw_dict[$name] = ltrim($value);
}
$headers = array('to' => $request->getStr('recipient'), 'from' => $request->getStr('from'), 'subject' => $request->getStr('subject')) + $raw_dict;
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders($headers);
$received->setBodies(array('text' => $request->getStr('stripped-text'), 'html' => $request->getStr('stripped-html')));
$file_phids = array();
foreach ($_FILES as $file_raw) {
try {
$file = PhabricatorFile::newFromPHPUpload($file_raw, array('viewPolicy' => PhabricatorPolicies::POLICY_NOONE));
$file_phids[] = $file->getPHID();
} catch (Exception $ex) {
phlog($ex);
}
}
$received->setAttachments($file_phids);
$received->save();
$received->processReceivedMail();
$response = new AphrontWebpageResponse();
$response->setContent(pht("Got it! Thanks, Mailgun!\n"));
return $response;
}
示例9: handleRequestException
public function handleRequestException(AphrontRequest $request, Exception $ex)
{
$viewer = $this->getViewer($request);
// Some types of uninteresting request exceptions don't get logged, usually
// because they are caused by the background radiation of bot traffic on
// the internet. These include requests with bad CSRF tokens and
// questionable "Host" headers.
$should_log = true;
if ($ex instanceof AphrontMalformedRequestException) {
$should_log = !$ex->getIsUnlogged();
}
if ($should_log) {
phlog($ex);
}
$class = get_class($ex);
$message = $ex->getMessage();
if ($ex instanceof AphrontSchemaQueryException) {
$message .= "\n\n" . pht("NOTE: This usually indicates that the MySQL schema has not been " . "properly upgraded. Run '%s' to ensure your schema is up to date.", 'bin/storage upgrade');
}
if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode')) {
$trace = id(new AphrontStackTraceView())->setUser($viewer)->setTrace($ex->getTrace());
} else {
$trace = null;
}
$content = phutil_tag('div', array('class' => 'aphront-unhandled-exception'), array(phutil_tag('div', array('class' => 'exception-message'), $message), $trace));
$dialog = new AphrontDialogView();
$dialog->setTitle(pht('Unhandled Exception ("%s")', $class))->setClass('aphront-exception-dialog')->setUser($viewer)->appendChild($content);
if ($request->isAjax()) {
$dialog->addCancelButton('/', pht('Close'));
}
return id(new AphrontDialogResponse())->setDialog($dialog)->setHTTPResponseCode(500);
}
示例10: setKeys
public function setKeys(array $keys, $ttl = null)
{
$this->validateKeys(array_keys($keys));
$this->lockCache(15);
if ($ttl) {
$ttl_epoch = time() + $ttl;
} else {
$ttl_epoch = null;
}
foreach ($keys as $key => $value) {
$dict = array('value' => $value);
if ($ttl_epoch) {
$dict['ttl'] = $ttl_epoch;
}
try {
$key_file = $this->getKeyFile($key);
$key_dir = dirname($key_file);
if (!Filesystem::pathExists($key_dir)) {
Filesystem::createDirectory($key_dir, $mask = 0755, $recursive = true);
}
$new_file = $key_file . '.new';
Filesystem::writeFile($new_file, serialize($dict));
Filesystem::rename($new_file, $key_file);
} catch (FilesystemException $ex) {
phlog($ex);
}
}
$this->unlockCache();
return $this;
}
示例11: establishConnection
private function establishConnection()
{
$host = $this->getConfiguration('host');
$database = $this->getConfiguration('database');
$profiler = PhutilServiceProfiler::getInstance();
$call_id = $profiler->beginServiceCall(array('type' => 'connect', 'host' => $host, 'database' => $database));
$retries = max(1, $this->getConfiguration('retries', 3));
while ($retries--) {
try {
$conn = $this->connect();
$profiler->endServiceCall($call_id, array());
break;
} catch (AphrontQueryException $ex) {
if ($retries && $ex->getCode() == 2003) {
$class = get_class($ex);
$message = $ex->getMessage();
phlog(pht('Retrying (%d) after %s: %s', $retries, $class, $message));
} else {
$profiler->endServiceCall($call_id, array());
throw $ex;
}
}
}
$this->connection = $conn;
}
示例12: indexDocumentByPHID
public function indexDocumentByPHID($phid)
{
try {
$document = $this->buildAbstractDocumentByPHID($phid);
$object = $this->loadDocumentByPHID($phid);
// Automatically rebuild CustomField indexes if the object uses custom
// fields.
if ($object instanceof PhabricatorCustomFieldInterface) {
$this->indexCustomFields($document, $object);
}
// Automatically rebuild subscriber indexes if the object is subscribable.
if ($object instanceof PhabricatorSubscribableInterface) {
$this->indexSubscribers($document);
}
$engine = PhabricatorSearchEngineSelector::newSelector()->newEngine();
try {
$engine->reindexAbstractDocument($document);
} catch (Exception $ex) {
$phid = $document->getPHID();
$class = get_class($engine);
phlog("Unable to index document {$phid} with engine {$class}.");
phlog($ex);
}
$this->dispatchDidUpdateIndexEvent($phid, $document);
} catch (Exception $ex) {
$class = get_class($this);
phlog("Unable to build document {$phid} with indexer {$class}.");
phlog($ex);
}
return $this;
}
示例13: addRemarkupSection
public function addRemarkupSection($text)
{
try {
$engine = PhabricatorMarkupEngine::newMarkupEngine(array());
$engine->setConfig('viewer', $this->getViewer());
$engine->setMode(PhutilRemarkupEngine::MODE_TEXT);
$styled_text = $engine->markupText($text);
$this->sections[] = $styled_text;
} catch (Exception $ex) {
phlog($ex);
$this->sections[] = $text;
}
try {
$mail_engine = PhabricatorMarkupEngine::newMarkupEngine(array());
$mail_engine->setConfig('viewer', $this->getViewer());
$mail_engine->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL);
$mail_engine->setConfig('uri.base', PhabricatorEnv::getProductionURI('/'));
$html = $mail_engine->markupText($text);
$this->htmlSections[] = $html;
} catch (Exception $ex) {
phlog($ex);
$this->htmlSections[] = phutil_escape_html_newlines(phutil_tag('div', array(), $text));
}
return $this;
}
示例14: execute
protected function execute(ConduitAPIRequest $request)
{
$results = array();
$user = $request->getUser();
$view_type = $request->getValue('view');
if (!$view_type) {
$view_type = 'data';
}
$limit = $request->getValue('limit');
if (!$limit) {
$limit = $this->getDefaultLimit();
}
$filter_phids = $request->getValue('filterPHIDs');
if (!$filter_phids) {
$filter_phids = array();
}
$query = id(new PhabricatorFeedQuery())->setLimit($limit)->setFilterPHIDs($filter_phids)->setViewer($user);
$after = $request->getValue('after');
if (strlen($after)) {
$query->setAfterID($after);
}
$before = $request->getValue('before');
if (strlen($before)) {
$query->setBeforeID($before);
}
$stories = $query->execute();
if ($stories) {
foreach ($stories as $story) {
$story_data = $story->getStoryData();
$data = null;
try {
$view = $story->renderView();
} catch (Exception $ex) {
// When stories fail to render, just fail that story.
phlog($ex);
continue;
}
$view->setEpoch($story->getEpoch());
$view->setUser($user);
switch ($view_type) {
case 'html':
$data = $view->render();
break;
case 'html-summary':
$data = $view->render();
break;
case 'data':
$data = array('class' => $story_data->getStoryType(), 'epoch' => $story_data->getEpoch(), 'authorPHID' => $story_data->getAuthorPHID(), 'chronologicalKey' => $story_data->getChronologicalKey(), 'data' => $story_data->getStoryData());
break;
case 'text':
$data = array('class' => $story_data->getStoryType(), 'epoch' => $story_data->getEpoch(), 'authorPHID' => $story_data->getAuthorPHID(), 'chronologicalKey' => $story_data->getChronologicalKey(), 'objectPHID' => $story->getPrimaryObjectPHID(), 'text' => $story->renderText());
break;
default:
throw new ConduitException('ERR-UNKNOWN-TYPE');
}
$results[$story_data->getPHID()] = $data;
}
}
return $results;
}
示例15: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$iterator = $this->buildIterator($args);
if (!$iterator) {
throw new PhutilArgumentUsageException(pht('Either specify a list of files to compact, or use `--all` ' . 'to compact all files.'));
}
$is_dry_run = $args->getArg('dry-run');
foreach ($iterator as $file) {
$monogram = $file->getMonogram();
$hash = $file->getContentHash();
if (!$hash) {
$console->writeOut("%s\n", pht('%s: No content hash.', $monogram));
continue;
}
// Find other files with the same content hash. We're going to point
// them at the data for this file.
$similar_files = id(new PhabricatorFile())->loadAllWhere('contentHash = %s AND id != %d AND
(storageEngine != %s OR storageHandle != %s)', $hash, $file->getID(), $file->getStorageEngine(), $file->getStorageHandle());
if (!$similar_files) {
$console->writeOut("%s\n", pht('%s: No other files with the same content hash.', $monogram));
continue;
}
// Only compact files into this one if we can load the data. This
// prevents us from breaking working files if we're missing some data.
try {
$data = $file->loadFileData();
} catch (Exception $ex) {
$data = null;
}
if ($data === null) {
$console->writeOut("%s\n", pht('%s: Unable to load file data; declining to compact.', $monogram));
continue;
}
foreach ($similar_files as $similar_file) {
if ($is_dry_run) {
$console->writeOut("%s\n", pht('%s: Would compact storage with %s.', $monogram, $similar_file->getMonogram()));
continue;
}
$console->writeOut("%s\n", pht('%s: Compacting storage with %s.', $monogram, $similar_file->getMonogram()));
$old_instance = null;
try {
$old_instance = $similar_file->instantiateStorageEngine();
$old_engine = $similar_file->getStorageEngine();
$old_handle = $similar_file->getStorageHandle();
} catch (Exception $ex) {
// If the old stuff is busted, we just won't try to delete the
// old data.
phlog($ex);
}
$similar_file->setStorageEngine($file->getStorageEngine())->setStorageHandle($file->getStorageHandle())->save();
if ($old_instance) {
$similar_file->deleteFileDataIfUnused($old_instance, $old_engine, $old_handle);
}
}
}
return 0;
}