function messageLogged(BuildEvent $event) { if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage() || trim($event->getMessage() === "")) { return; } if ($this->targetName !== null) { $msg = PHP_EOL . $event->getProject()->getName() . ' > ' . $this->targetName . ':' . PHP_EOL; $this->printMessage($msg, $this->out, $event->getPriority()); $this->targetName = null; } parent::messageLogged($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 $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()); }
/** * Sets the start-time when the build started. Used for calculating * the build-time. * * @param BuildEvent The BuildEvent */ public function buildStarted(BuildEvent $event) { $this->startTime = Phing::currentTimeMillis(); $this->logger()->setIdent($event->getProject()->getName()); $this->logger()->info("Starting build with buildfile: " . $event->getProject()->getProperty("phing.file")); }
/** * Prints the current target name * * @param object The BuildEvent * @access public * @see BuildEvent::getTarget() */ public function targetStarted(BuildEvent $event) { if (Project::MSG_INFO <= $this->msgOutputLevel) { $msg = PHP_EOL . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ':' . PHP_EOL; $this->printMessage($msg, $this->out, $event->getPriority()); } }
/** * Cleans up any resources held by this recorder entry at the end * of a subbuild if it has been created for the subbuild's project * instance. * * @param BuildEvent $event the buildFinished event */ public function subBuildFinished(BuildEvent $event) { if ($event->getProject() == $this->project) { $this->cleanup(); } }
/** * 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); }
/** * Prints the current target name * * @param BuildEvent $event * @see BuildEvent::getTarget() */ public function targetStarted(BuildEvent $event) { if (Project::MSG_INFO <= $this->msgOutputLevel && $event->getTarget()->getName() != '') { $showLongTargets = $event->getProject()->getProperty("phing.showlongtargets"); $msg = PHP_EOL . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ($showLongTargets ? ' [' . $event->getTarget()->getDescription() . ']' : '') . ':' . PHP_EOL; $this->printMessage($msg, $this->out, $event->getPriority()); } }
/** * Prints the current target name * * @param object The BuildEvent * @access public * @see BuildEvent::getTarget() */ function targetStarted(BuildEvent $event) { if (PROJECT_MSG_INFO <= $this->msgOutputLevel) { print $this->lSep . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ':' . $this->lSep; } }
/** * 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(); }
/** * Handles the Phing message logged event. * * @param BuildEvent The Phing build event. * * @author Noah Fontes <*****@*****.**> * @since 1.0.0 */ public function messageLogged(BuildEvent $phingEvent) { $event = new AgaviPhingMessageEvent(); $event->setSource($phingEvent->getSource()); $event->setMessage($phingEvent->getMessage()); $event->setPriority($phingEvent->getPriority()); $event->setProject($phingEvent->getProject()); foreach ($this->messageListeners as $listener) { $listener->messageReported($event); } }