本文整理汇总了PHP中BuildEvent::getException方法的典型用法代码示例。如果您正苦于以下问题:PHP BuildEvent::getException方法的具体用法?PHP BuildEvent::getException怎么用?PHP BuildEvent::getException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BuildEvent
的用法示例。
在下文中一共展示了BuildEvent::getException方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildFinished
/**
* Fired when the build finishes, this adds the time taken and any
* error stacktrace to the build element and writes the document to disk.
*
* @param BuildEvent $event An event with any relevant extra information.
* Will not be <code>null</code>.
* @throws BuildException
*/
public function buildFinished(BuildEvent $event)
{
$elapsedTime = Phing::currentTimeMillis() - $this->getBuildTimerStart();
$this->getBuildElement()->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime));
if ($event->getException() != null) {
$this->getBuildElement()->setAttribute(XmlLogger::ERROR_ATTR, $event->getException()->getMessage());
$errText = $this->getDoc()->createCDATASection($event->getException()->getTraceAsString());
$stacktrace = $this->getDoc()->createElement(XmlLogger::STACKTRACE_TAG);
$stacktrace->appendChild($errText);
$this->getBuildElement()->appendChild($stacktrace);
}
$this->getDoc()->appendChild($this->getBuildElement());
$outFilename = $event->getProject()->getProperty("JsonLogger.file");
if ($outFilename == null) {
$outFilename = "log.json";
}
try {
$stream = $this->getOut();
if ($stream === null) {
$stream = new FileOutputStream($outFilename);
}
$writer = new OutputStreamWriter($stream);
$writer->write($this->xml2js(simplexml_import_dom($this->getDoc())));
$writer->close();
} catch (IOException $exc) {
try {
$stream->close();
// in case there is a stream open still ...
} catch (Exception $x) {
}
throw new BuildException("Unable to write log file.", $exc);
}
// cleanup:remove the buildElement
$this->setBuildElement(null);
array_pop($this->getElementStack());
array_pop($this->getTimesStack());
}
示例2: buildFinished
/**
* Logs whether the build succeeded or failed, and any errors that
* occured during the build. Also outputs the total build-time.
*
* @param BuildEvent The BuildEvent
*
* @see BuildEvent::getException()
*/
public function buildFinished(BuildEvent $event)
{
$error = $event->getException();
if ($error === null) {
$msg = "Finished successful build.";
} else {
$msg = "Build failed. [reason: " . $error->getMessage() . "]";
}
$this->logger()->log($msg . " Total time: " . DefaultLogger::formatTime(Phing::currentTimeMillis() - $this->startTime));
}
示例3: buildFinished
/**
* Prints whether the build succeeded or failed, and any errors that
* occured during the build. Also outputs the total build-time.
*
* @param object The BuildEvent
* @see BuildEvent::getException()
*/
public function buildFinished(BuildEvent $event)
{
$error = $event->getException();
if ($error === null) {
$msg = PHP_EOL . $this->getBuildSuccessfulMessage() . PHP_EOL;
} else {
$msg = PHP_EOL . $this->getBuildFailedMessage() . PHP_EOL;
if (Project::MSG_VERBOSE <= $this->msgOutputLevel || !$error instanceof BuildException) {
$msg .= $error->__toString() . PHP_EOL;
} else {
$msg .= $error->getMessage();
}
}
$msg .= PHP_EOL . "Total time: " . self::formatTime(Phing::currentTimeMillis() - $this->startTime) . PHP_EOL;
if ($error === null) {
$this->printMessage($msg, $this->out, Project::MSG_VERBOSE);
} else {
$this->printMessage($msg, $this->err, Project::MSG_ERR);
}
}
示例4: buildFinished
/** {@inheritDoc}. */
public function buildFinished(BuildEvent $event)
{
$this->log("< BUILD FINISHED", Project::MSG_DEBUG);
if ($this->record && $this->out != null) {
$error = $event->getException();
if ($error == null) {
$this->out->write(Phing::getProperty('line.separator') . "BUILD SUCCESSFUL" . PHP_EOL);
} else {
$this->out->write(Phing::getProperty('line.separator') . "BUILD FAILED" . Phing::getProperty('line.separator') . PHP_EOL);
$this->out->write($error->getTraceAsString());
}
}
$this->cleanup();
}
示例5: buildFinished
/**
* Prints whether the build failed, and any errors that occured during
the build. Also outputs the total build-time on completion.
*
* @param object The BuildEvent
* @access public
* @see BuildEvent::getException()
*/
function buildFinished(BuildEvent $event)
{
$error = $event->getException();
if ($error !== null) {
print $this->lSep . "BUILD FAILED" . $this->lSep;
if (PROJECT_MSG_VERBOSE <= $this->msgOutputLevel || !$error instanceof BuildException) {
print $error->__toString() . $this->lSep;
} else {
print $error->getMessage();
}
}
print $this->lSep . "Total time: " . $this->_formatTime(Phing::currentTimeMillis() - $this->startTime) . $this->lSep;
}
示例6: buildFinished
/**
* Fired when the build finishes, this adds the time taken and any
* error stacktrace to the build element and writes the document to disk.
*
* @param BuildEvent $event An event with any relevant extra information.
* Will not be <code>null</code>.
* @throws BuildException
*/
public function buildFinished(BuildEvent $event)
{
$elapsedTime = Phing::currentTimeMillis() - $this->buildTimerStart;
$this->buildElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime));
if ($event->getException() != null) {
$this->buildElement->setAttribute(XmlLogger::ERROR_ATTR, $event->getException()->getMessage());
$errText = $this->doc->createCDATASection($event->getException()->getTraceAsString());
$stacktrace = $this->doc->createElement(XmlLogger::STACKTRACE_TAG);
$stacktrace->appendChild($errText);
$this->buildElement->appendChild($stacktrace);
}
$this->doc->appendChild($this->buildElement);
$outFilename = $event->getProject()->getProperty("XmlLogger.file");
if ($outFilename == null) {
$outFilename = "log.xml";
}
try {
$stream = $this->out;
if ($stream === null) {
$stream = new FileOutputStream($outFilename);
}
// Yes, we could just stream->write() but this will eventually be the better
// way to do this (when we need to worry about charset conversions.
$writer = new OutputStreamWriter($stream);
$writer->write($this->doc->saveXML());
$writer->close();
} catch (IOException $exc) {
try {
$stream->close();
// in case there is a stream open still ...
} catch (Exception $x) {
}
throw new BuildException("Unable to write log file.", $exc);
}
// cleanup:remove the buildElement
$this->buildElement = null;
array_pop($this->elementStack);
array_pop($this->timesStack);
}
示例7: buildFinished
public function buildFinished(BuildEvent $event)
{
if ($event->getException() != null) {
parent::buildFinished($event);
}
}
示例8: buildFinished
/**
* Fired when the build finishes, this adds the time taken and any
* error stacktrace to the build element and writes the document to disk.
*
* @param BuildEvent An event with any relevant extra information.
* Will not be <code>null</code>.
*/
function buildFinished(BuildEvent $event)
{
$this->buildTimer->stop();
$elapsedTime = Phing::currentTimeMillis() - $this->buildTimerStart;
$this->buildElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::_formatTime($elapsedTime));
if ($event->getException() != null) {
$this->buildElement->setAttribute(XmlLogger::ERROR_ATTR, $event->getException()->toString());
$errText = $this->doc->createCDATASection($event->getException()->getTraceAsString());
$stacktrace = $this->doc->createElement(XmlLogger::STACKTRACE_TAG);
$stacktrace->appendChild($errText);
$this->buildElement->appendChild($stacktrace);
}
$outFilename = $event->getProject()->getProperty("XmlLogger.file");
if ($outFilename == "") {
$outFilename = "log.xml";
}
$writer = new FileWriter($outFilename);
$writer->write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
$writer->write($this->doc->saveXML($this->buildElement));
$writer->close();
}
示例9: targetFinished
/**
* Fired when a target has finished.
*
* @param BuildEvent The BuildEvent
* @see BuildEvent#getException()
*/
public function targetFinished(BuildEvent $event)
{
if (null !== $event->getException()) {
self::$exceptions[] = $event->getException();
}
}
示例10: buildFinished
/**
* Logs the end of a build.
*
* @param BuildEvent An event containing the data to be logged.
*
* @see DefaultLogger::buildFinished()
*
* @author Noah Fontes <noah.fontes@bitextender.com>
* @since 1.0.0
*/
public function buildFinished(BuildEvent $event)
{
$exception = $event->getException();
if ($exception !== null) {
$this->printMessage(str_pad('[error] ', DefaultLogger::LEFT_COLUMN_SIZE, ' ', STR_PAD_LEFT) . $exception->getMessage(), $this->out, $event->getPriority());
}
}
示例11: messageLogged
/**
* Fired whenever a message is logged.
*
* @param BuildEvent The BuildEvent
*
* @see BuildEvent::getMessage()
*/
public function messageLogged(BuildEvent $event)
{
$logger = Xinc_Logger::getInstance();
/**
* write to a temporary logfile
* - which will be read afterwards and the logentries will
* - be used to determine the status of the build
*/
switch ($event->getPriority()) {
case self::MSG_DEBUG:
case self::MSG_VERBOSE:
$logger->debug('[phing] ' . $event->getMessage());
break;
case self::MSG_INFO:
$logger->info('[phing] ' . $event->getMessage());
break;
case self::MSG_WARN:
$logger->warn('[phing] ' . $event->getMessage());
break;
case self::MSG_ERR:
$logger->error('[phing] ' . $event->getMessage());
Xinc::getCurrentBuild()->setStatus(Xinc_Build_Interface::FAILED);
break;
}
$exception = $event->getException();
if ($exception != null) {
$logger->error('[phing] ' . $exception->getMessage());
Xinc::getCurrentBuild()->setStatus(Xinc_Build_Interface::FAILED);
}
}