本文整理汇总了PHP中DefaultLogger::formatTime方法的典型用法代码示例。如果您正苦于以下问题:PHP DefaultLogger::formatTime方法的具体用法?PHP DefaultLogger::formatTime怎么用?PHP DefaultLogger::formatTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DefaultLogger
的用法示例。
在下文中一共展示了DefaultLogger::formatTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: taskFinished
/**
* Fired when a task finishes building, this adds the time taken
* to the appropriate task element in the log.
*
* @param BuildEvent $event An event with any relevant extra information.
* Will not be <code>null</code>.
*/
public function taskFinished(BuildEvent $event)
{
$taskTimerStart = array_pop($this->timesStack);
$taskElement = array_pop($this->elementStack);
$elapsedTime = Phing::currentTimeMillis() - $taskTimerStart;
$taskElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime));
$parentElement = $this->elementStack[count($this->elementStack) - 1];
$parentElement->appendChild($taskElement);
}