mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 06:22:42 +01:00
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.
This commit is contained in:
parent
7a04839ea5
commit
cd92ea5885
3 changed files with 64 additions and 42 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue