Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
Show All 22 Lines | final class HarbormasterBuildLog extends HarbormasterDAO | ||||
public static function initializeNewBuildLog( | public static function initializeNewBuildLog( | ||||
HarbormasterBuild $build, | HarbormasterBuild $build, | ||||
HarbormasterBuildStep $build_step) { | HarbormasterBuildStep $build_step) { | ||||
return id(new HarbormasterBuildLog()) | return id(new HarbormasterBuildLog()) | ||||
->setBuildPHID($build->getPHID()) | ->setBuildPHID($build->getPHID()) | ||||
->setBuildStepPHID($build_step->getPHID()) | ->setBuildStepPHID($build_step->getPHID()) | ||||
->setDuration(null) | ->setDuration(null) | ||||
->setLive(false); | ->setLive(0); | ||||
} | } | ||||
public function getConfiguration() { | public function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
Show All 25 Lines | public function getBuildStep() { | ||||
return $this->assertAttached($this->buildStep); | return $this->assertAttached($this->buildStep); | ||||
} | } | ||||
public function start() { | public function start() { | ||||
if ($this->getLive()) { | if ($this->getLive()) { | ||||
throw new Exception("Live logging has already started for this log."); | throw new Exception("Live logging has already started for this log."); | ||||
} | } | ||||
$this->setLive(true); | $this->setLive(1); | ||||
$this->save(); | $this->save(); | ||||
return time(); | return time(); | ||||
} | } | ||||
public function append($content) { | public function append($content) { | ||||
if (!$this->getLive()) { | if (!$this->getLive()) { | ||||
throw new Exception("Start logging before appending data to the log."); | throw new Exception("Start logging before appending data to the log."); | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (!$this->getLive()) { | ||||
throw new Exception("Start logging before finalizing it."); | throw new Exception("Start logging before finalizing it."); | ||||
} | } | ||||
// TODO: Encode the log contents in a gzipped format. | // TODO: Encode the log contents in a gzipped format. | ||||
$this->reload(); | $this->reload(); | ||||
if ($start > 0) { | if ($start > 0) { | ||||
$this->setDuration(time() - $start); | $this->setDuration(time() - $start); | ||||
} | } | ||||
$this->setLive(false); | $this->setLive(0); | ||||
$this->save(); | $this->save(); | ||||
} | } | ||||
public function getLogText() { | public function getLogText() { | ||||
// TODO: This won't cope very well if we're pulling like a 700MB | // TODO: This won't cope very well if we're pulling like a 700MB | ||||
// log file out of the DB. We should probably implement some sort | // log file out of the DB. We should probably implement some sort | ||||
// of optional limit parameter so that when we're rendering out only | // of optional limit parameter so that when we're rendering out only | ||||
// 25 lines in the UI, we don't wastefully read in the whole log. | // 25 lines in the UI, we don't wastefully read in the whole log. | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |