aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/logging.hh
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2022-02-19 22:34:50 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2022-02-28 17:27:52 +0100
commitcd92ea588504db697103d3ff56166fe61e6da131 (patch)
tree86bb62fe1e4aedfc8f48e87611bd1f7b89daee90 /src/libutil/logging.hh
parent7a04839ea53986a0175bf085e7d061ab8a32d59b (diff)
libstore/derivation-goal: avoid double-parsing of JSON messages
To avoid that JSON messages are parsed twice in case of remote builds with `ssh-ng://`, I split up the original `handleJSONLogMessage` into three parts: * `parseJSONMessage(const std::string&)` checks if it's a message in the form of `@nix {...}` and tries to parse it (and prints an error if the parsing fails). * `handleJSONLogMessage(nlohmann::json&, ...)` reads the fields from the message and passes them to the logger. * `handleJSONLogMessage(const std::string&, ...)` behaves as before, but uses the two functions mentioned above as implementation. In case of `ssh-ng://`-logs the first two methods are invoked manually.
Diffstat (limited to 'src/libutil/logging.hh')
-rw-r--r--src/libutil/logging.hh8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index bd28036ae..9ab2091c7 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -4,6 +4,8 @@
#include "error.hh"
#include "config.hh"
+#include <nlohmann/json.hpp>
+
namespace nix {
typedef enum {
@@ -166,6 +168,12 @@ Logger * makeSimpleLogger(bool printBuildLogs = true);
Logger * makeJSONLogger(Logger & prevLogger);
+std::optional<nlohmann::json> parseJSONMessage(const std::string & msg);
+
+bool handleJSONLogMessage(nlohmann::json & json,
+ const Activity & act, std::map<ActivityId, Activity> & activities,
+ bool trusted);
+
bool handleJSONLogMessage(const std::string & msg,
const Activity & act, std::map<ActivityId, Activity> & activities,
bool trusted);