@@ -280,20 +280,22 @@ static Logger::Fields getFields(nlohmann::json & json)
280280 return fields;
281281}
282282
283- std::optional<nlohmann::json> parseJSONMessage (const std::string & msg)
283+ std::optional<nlohmann::json> parseJSONMessage (const std::string & msg, std::string_view source )
284284{
285285 if (!hasPrefix (msg, " @nix " )) return std::nullopt ;
286286 try {
287287 return nlohmann::json::parse (std::string (msg, 5 ));
288288 } catch (std::exception & e) {
289- printError (" bad JSON log message from builder: %s" , e.what ());
289+ printError (" bad JSON log message from %s: %s" ,
290+ Uncolored (source),
291+ e.what ());
290292 }
291293 return std::nullopt ;
292294}
293295
294296bool handleJSONLogMessage (nlohmann::json & json,
295297 const Activity & act, std::map<ActivityId, Activity> & activities,
296- bool trusted)
298+ std::string_view source, bool trusted)
297299{
298300 try {
299301 std::string action = json[" action" ];
@@ -329,20 +331,21 @@ bool handleJSONLogMessage(nlohmann::json & json,
329331 return true ;
330332 } catch (const nlohmann::json::exception &e) {
331333 warn (
332- " warning: Unable to handle a JSON message from the builder: %s" ,
334+ " warning: Unable to handle a JSON message from %s: %s" ,
335+ Uncolored (source),
333336 e.what ()
334337 );
335338 return false ;
336339 }
337340}
338341
339342bool handleJSONLogMessage (const std::string & msg,
340- const Activity & act, std::map<ActivityId, Activity> & activities, bool trusted)
343+ const Activity & act, std::map<ActivityId, Activity> & activities, std::string_view source, bool trusted)
341344{
342- auto json = parseJSONMessage (msg);
345+ auto json = parseJSONMessage (msg, source );
343346 if (!json) return false ;
344347
345- return handleJSONLogMessage (*json, act, activities, trusted);
348+ return handleJSONLogMessage (*json, act, activities, source, trusted);
346349}
347350
348351Activity::~Activity ()
0 commit comments