本文整理汇总了PHP中DefaultLogger类的典型用法代码示例。如果您正苦于以下问题:PHP DefaultLogger类的具体用法?PHP DefaultLogger怎么用?PHP DefaultLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DefaultLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildFinished
/**
* Sends the mail
*
* @see DefaultLogger#buildFinished
* @param BuildEvent $event
*/
public function buildFinished(BuildEvent $event)
{
parent::buildFinished($event);
if (empty($this->_tolist)) {
return;
}
$hdrs = array('From' => $this->_from, 'Subject' => $this->_subject . (empty($event) ? " (build succesful)" : " (build failed)"));
$mail = Mail::factory('mail');
$mail->send($this->_tolist, $hdrs, $this->_mailMessage);
}
示例2: buildFinished
/**
* Sends the mail
*
* @see DefaultLogger#buildFinished
* @param BuildEvent $event
*/
public function buildFinished(BuildEvent $event)
{
parent::buildFinished($event);
$project = $event->getProject();
$properties = $project->getProperties();
$filename = $properties['phing.log.mail.properties.file'];
// overlay specified properties file (if any), which overrides project
// settings
$fileProperties = new Properties();
$file = new PhingFile($filename);
try {
$fileProperties->load($file);
} catch (IOException $ioe) {
// ignore because properties file is not required
}
foreach ($fileProperties as $key => $value) {
$properties['key'] = $project->replaceProperties($value);
}
$success = $event->getException() === null;
$prefix = $success ? 'success' : 'failure';
try {
$notify = StringHelper::booleanValue($this->getValue($properties, $prefix . '.notify', 'on'));
if (!$notify) {
return;
}
if (is_string(Phing::getDefinedProperty('phing.log.mail.subject'))) {
$defaultSubject = Phing::getDefinedProperty('phing.log.mail.subject');
} else {
$defaultSubject = $success ? 'Build Success' : 'Build Failure';
}
$hdrs = array();
$hdrs['From'] = $this->getValue($properties, 'from', $this->from);
$hdrs['Reply-To'] = $this->getValue($properties, 'replyto', '');
$hdrs['Cc'] = $this->getValue($properties, $prefix . '.cc', '');
$hdrs['Bcc'] = $this->getValue($properties, $prefix . '.bcc', '');
$hdrs['Body'] = $this->getValue($properties, $prefix . '.body', '');
$hdrs['Subject'] = $this->getValue($properties, $prefix . '.subject', $defaultSubject);
$tolist = $this->getValue($properties, $prefix . '.to', $this->tolist);
} catch (BadMethodCallException $e) {
$project->log($e->getMessage(), Project::MSG_WARN);
}
if (empty($tolist)) {
return;
}
$mail = Mail::factory('mail');
$mail->send($tolist, $hdrs, $this->mailMessage);
}
示例3: 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());
}
示例4: 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));
}
示例5: createLogger
/**
* Creates the default build logger for sending build events to the log.
* @return BuildLogger The created Logger
*/
private function createLogger()
{
if ($this->loggerClassname !== null) {
self::import($this->loggerClassname);
// get class name part
$classname = self::import($this->loggerClassname);
$logger = new $classname();
if (!$logger instanceof BuildLogger) {
throw new BuildException($classname . ' does not implement the BuildLogger interface.');
}
} else {
require_once 'phing/listener/DefaultLogger.php';
$logger = new DefaultLogger();
}
$logger->setMessageOutputLevel(self::$msgOutputLevel);
$logger->setOutputStream(self::$out);
$logger->setErrorStream(self::$err);
return $logger;
}
示例6: 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);
}
示例7: createLogger
/**
* Creates the default build logger for sending build events to the log.
* @return BuildListener The created Logger
*/
private function createLogger()
{
if ($this->loggerClassname !== null) {
self::import($this->loggerClassname);
// get class name part
$classname = self::import($this->loggerClassname);
$logger = new $classname();
} else {
require_once 'phing/listener/DefaultLogger.php';
$logger = new DefaultLogger();
}
$logger->setMessageOutputLevel(self::$msgOutputLevel);
return $logger;
}
示例8: taskFinished
/**
* Fired when a task finishes building, this adds the time taken
* to the appropriate task element in the log.
*
* @param BuildEvent An event with any relevant extra information.
* Will not be <code>null</code>.
*/
function taskFinished(BuildEvent $event)
{
$task = $event->getTask();
$elapsedTime = Phing::currentTimeMillis() - $this->taskTimerStart;
$this->taskElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::_formatTime($elapsedTime));
$this->targetElement->appendChild($this->taskElement);
}
示例9: setErrorStream
/**
* Sets the error stream for the logging.
*
* @param OutputStream The error stream.
*
* @see DefaultLogger::setOutputStream()
*
* @author Noah Fontes <noah.fontes@bitextender.com>
* @since 1.0.0
*/
public function setErrorStream(OutputStream $error)
{
parent::setErrorStream($error);
$this->logger->setErrorStream($error);
}
示例10: testError
public function testError()
{
$logger = new DefaultLogger();
$this->expectOutputString("[" . date('Y-m-d H:i:s') . "][ERROR] test msg\n");
$logger->error('test msg');
}
示例11: __construct
/**
* Construct new HtmlColorLogger
* Perform initializations that cannot be done in var declarations.
*/
public function __construct()
{
parent::__construct();
$this->errColor = self::PREFIX . self::CLASS_ERR . self::SUFFIX;
$this->warnColor = self::PREFIX . self::CLASS_WARN . self::SUFFIX;
$this->infoColor = self::PREFIX . self::CLASS_INFO . self::SUFFIX;
$this->verboseColor = self::PREFIX . self::CLASS_VERBOSE . self::SUFFIX;
$this->debugColor = self::PREFIX . self::CLASS_DEBUG . self::SUFFIX;
}
示例12: messageLogged
function messageLogged(BuildEvent $event)
{
if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage() || trim($event->getMessage() === "")) {
return;
}
if ($this->targetName !== null) {
print $this->lSep . "Target: " . $this->targetName . $this->lSep;
$this->targetName = null;
}
parent::messageLogged($event);
}
示例13: messageLogged
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);
}
示例14: __construct
/**
* Construct new AnsiColorLogger
* Perform initializations that cannot be done in var declarations.
*/
public function __construct()
{
parent::__construct();
$this->errColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_RED . self::SUFFIX;
$this->warnColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_MAGENTA . self::SUFFIX;
$this->infoColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_CYAN . self::SUFFIX;
$this->verboseColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_GREEN . self::SUFFIX;
$this->debugColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_BLUE . self::SUFFIX;
}
示例15: buildFinished
public function buildFinished(BuildEvent $event)
{
if ($event->getException() != null) {
parent::buildFinished($event);
}
}