about summary refs log tree commit diff
path: root/src/nix/log.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-29T14·18+0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-29T14·18+0200
commite9c07a3b26a1e3056538a8fce49c9f7d9f1d8aba (patch)
treeb6e5559aeaa066cbb454876d1cdbffcd7582ad45 /src/nix/log.cc
parent9b82ecbae04e36cb8f009510716268fa72a067b8 (diff)
nix edit / log: Operate on a single Installable
Diffstat (limited to 'src/nix/log.cc')
-rw-r--r--src/nix/log.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/nix/log.cc b/src/nix/log.cc
index 0fb45c1454cb..ba5e71c10a08 100644
--- a/src/nix/log.cc
+++ b/src/nix/log.cc
@@ -2,10 +2,11 @@
 #include "common-args.hh"
 #include "shared.hh"
 #include "store-api.hh"
+#include "progress-bar.hh"
 
 using namespace nix;
 
-struct CmdLog : InstallablesCommand
+struct CmdLog : InstallableCommand
 {
     CmdLog()
     {
@@ -27,21 +28,22 @@ struct CmdLog : InstallablesCommand
 
         subs.push_front(store);
 
-        for (auto & inst : installables) {
-            for (auto & b : inst->toBuildable()) {
-                auto path = b.second.drvPath != "" ? b.second.drvPath : b.first;
-                bool found = false;
-                for (auto & sub : subs) {
-                    auto log = sub->getBuildLog(path);
+        for (auto & b : installable->toBuildable(true)) {
+
+            for (auto & sub : subs) {
+                auto log = b.second.drvPath != "" ? sub->getBuildLog(b.second.drvPath) : nullptr;
+                if (!log) {
+                    log = sub->getBuildLog(b.first);
                     if (!log) continue;
-                    std::cout << *log;
-                    found = true;
-                    break;
                 }
-                if (!found)
-                    throw Error("build log of path '%s' is not available", path);
+                stopProgressBar();
+                printInfo("got build log for '%s' from '%s'", b.first, sub->getUri());
+                std::cout << *log;
+                return;
             }
         }
+
+        throw Error("build log of '%s' is not available", installable->what());
     }
 };