about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-21T10·10+0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-21T10·18+0200
commit1f56235438984d8079159d7c81ad4127c318b2dc (patch)
tree60a44f6dc9307d6de684c631deab27b5e83dcec3 /src/libstore
parent4af2611bd105f365e568069463b1700d141dd0a8 (diff)
Clean up JSON construction
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 3663c33b012b..e97fcc9e269c 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2407,17 +2407,32 @@ struct BuilderLogger : Logger
 
     void startActivity(ActivityId act, ActivityType type, const std::string & s) override
     {
-        log(lvlError, fmt("@nix {\"action\": \"start\", \"id\": %d, \"type\": %d, \"text\": \"%s\"}", act, type, s));
+        nlohmann::json json;
+        json["action"] = "start";
+        json["id"] = act;
+        json["type"] = type;
+        json["text"] = s;
+        log(lvlError, "@nix " + json.dump());
     }
 
     void stopActivity(ActivityId act) override
     {
-        log(lvlError, fmt("@nix {\"action\": \"stop\", \"id\": %d}", act));
+        nlohmann::json json;
+        json["action"] = "stop";
+        json["id"] = act;
+        log(lvlError, "@nix " + json.dump());
     }
 
     void progress(ActivityId act, uint64_t done = 0, uint64_t expected = 0, uint64_t running = 0, uint64_t failed = 0) override
     {
-        log(lvlError, fmt("@nix {\"action\": \"progress\", \"id\": %d, \"done\": %d, \"expected\": %d, \"running\": %d, \"failed\": %d}", act, done, expected, running, failed));
+        nlohmann::json json;
+        json["action"] = "progress";
+        json["id"] = act;
+        json["done"] = done;
+        json["expected"] = expected;
+        json["running"] = running;
+        json["failed"] = failed;
+        log(lvlError, "@nix " + json.dump());
     }
 };