示例#1
0
 /**
  * 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());
 }
 /**
  *  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));
 }
 /**
  *  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
0
 /** {@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();
 }
 /**
 *  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
0
 /**
  * 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);
 }
 public function buildFinished(BuildEvent $event)
 {
     if ($event->getException() != null) {
         parent::buildFinished($event);
     }
 }
 /**
  * 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
0
 /**
  * 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();
     }
 }
 /**
  * Logs the end of a build.
  *
  * @param      BuildEvent An event containing the data to be logged.
  *
  * @see        DefaultLogger::buildFinished()
  *
  * @author     Noah Fontes <*****@*****.**>
  * @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
0
 /**
  *  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);
     }
 }