feat(tvix): Write build logs into the build log sink

This *should* wire up the builder's logs all the way back through the
gRPC client, where they are then conveniently discarded.

Change-Id: I65f22526d0b5a8b8d90f28665bc1b4bc7f7c802a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1825
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2020-08-21 01:53:36 +01:00 committed by tazjin
parent e08f36c32f
commit 262af89f81

View file

@ -1473,7 +1473,7 @@ void DerivationGoal::tryToBuild() {
if (hook) { if (hook) {
msg += fmt(" on '%s'", machineName); msg += fmt(" on '%s'", machineName);
} }
LOG(INFO) << msg << "[" << drvPath << "]"; log_sink_ << msg << "[" << drvPath << "]";
mcRunningBuilds = mcRunningBuilds =
std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds); std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds);
}; };
@ -3782,6 +3782,7 @@ void DerivationGoal::deleteTmpDir(bool force) {
} }
} }
// TODO(tazjin): What ... what does this function ... do?
void DerivationGoal::handleChildOutput(int fd, const std::string& data) { void DerivationGoal::handleChildOutput(int fd, const std::string& data) {
if ((hook && fd == hook->builderOut.readSide.get()) || if ((hook && fd == hook->builderOut.readSide.get()) ||
(!hook && fd == builderOut.readSide.get())) { (!hook && fd == builderOut.readSide.get())) {
@ -3824,7 +3825,7 @@ void DerivationGoal::handleChildOutput(int fd, const std::string& data) {
} }
} }
void DerivationGoal::handleEOF(int fd) { void DerivationGoal::handleEOF(int /* fd */) {
if (!currentLogLine.empty()) { if (!currentLogLine.empty()) {
flushLine(); flushLine();
} }
@ -3834,7 +3835,7 @@ void DerivationGoal::handleEOF(int fd) {
void DerivationGoal::flushLine() { void DerivationGoal::flushLine() {
if (settings.verboseBuild && if (settings.verboseBuild &&
(settings.printRepeatedBuilds || curRound == 1)) { (settings.printRepeatedBuilds || curRound == 1)) {
LOG(INFO) << currentLogLine; log_sink_ << currentLogLine;
} else { } else {
logTail.push_back(currentLogLine); logTail.push_back(currentLogLine);
if (logTail.size() > settings.logLines) { if (logTail.size() > settings.logLines) {