#include <systemd/sd-event.h>
+#include <pakfire/base64.h>
#include <pakfire/build.h>
#include <pakfire/config.h>
#include <pakfire/constants.h>
const struct timeval* timestamp, int priority, const char* line, size_t length) {
struct json_object* message = NULL;
struct json_object* data = NULL;
+ char* base64 = NULL;
char buffer[64];
int r;
+ // Encode the line to base64
+ r = pakfire_b64encode(&base64, (const unsigned char*)line, length);
+ if (r < 0) {
+ ERROR(job->ctx, "Failed to encode the log line: %s\n", strerror(-r));
+ goto ERROR;
+ }
+
// Create a new JSON object
data = json_object_new_object();
if (!data) {
goto ERROR;
// Add the line
- r = pakfire_json_add_stringn(data, "line", line, length);
+ r = pakfire_json_add_string(data, "line", base64);
if (r)
goto ERROR;
json_object_put(message);
if (data)
json_object_put(data);
+ if (base64)
+ free(base64);
return r;
}