From: Michael Tremer Date: Sun, 26 Jan 2025 16:53:20 +0000 (+0000) Subject: job: Write all received logs into the buffer only X-Git-Tag: 0.9.30~365 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d5663cc49114db63fc72af67c2d4edf5445a3d7;p=pakfire.git job: Write all received logs into the buffer only Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/job.c b/src/pakfire/job.c index 457d0f73..a787804b 100644 --- a/src/pakfire/job.c +++ b/src/pakfire/job.c @@ -379,69 +379,7 @@ int pakfire_job_exited(sd_event_source* s, const siginfo_t* si, void* data) { } static int pakfire_job_send_log(struct pakfire_job* job, int priority, const char* line, size_t length) { - struct json_object* message = NULL; - struct json_object* data = NULL; - int r; - - // Bail if we don't have a control connection - if (!job->control) { - DEBUG(job->ctx, "Cannot send log message because the control connection is down\n"); - return 0; - } - - // Create a new JSON object - data = json_object_new_object(); - if (!data) { - ERROR(job->ctx, "Could not create a new JSON object: %m\n"); - r = -errno; - goto ERROR; - } - - // Add the priority - r = pakfire_json_add_uint64(data, "priority", priority); - if (r) - goto ERROR; - - // Add the line - r = pakfire_json_add_stringn(data, "line", line, length); - if (r) - goto ERROR; - - // Create a new stats object - message = json_object_new_object(); - if (!message) { - r = -errno; - goto ERROR; - } - - // Set type - r = pakfire_json_add_string(message, "type", "log"); - if (r) - goto ERROR; - - // Set data - r = json_object_object_add(message, "data", json_object_get(data)); - if (r) - goto ERROR; - - // Serialize to string - const char* m = json_object_to_json_string_length(message, - JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY, &length); - - // Send the message - r = pakfire_xfer_send_message(job->control, m, length); - if (r) { - ERROR(job->ctx, "Could not send log message: %s\n", strerror(-r)); - goto ERROR; - } - -ERROR: - if (message) - json_object_put(message); - if (data) - json_object_put(data); - - return r; + return pakfire_log_buffer_enqueue(job->log.buffer, priority, line, length); } static int pakfire_job_stdout(struct pakfire_log_stream* stream,