pakfire_log_stream_unref(job->log.stderr);
if (job->log.stream)
sd_event_source_unref(job->log.stream);
+ if (job->log.file)
+ pakfire_log_file_unref(job->log.file);
if (job->client)
pakfire_client_unref(job->client);
DEBUG(job->ctx, "Job %s has finished with status %d\n", job->id, status);
+ // Close the log file
+ r = pakfire_log_file_close(job->log.file);
+ if (r < 0) {
+ ERROR(job->ctx, "Could not close the log file: %s\n", strerror(-r));
+ goto ERROR;
+ }
+
// Fetch the filename of the log file
filename = pakfire_log_file_filename(job->log.file);
if (!filename) {
static int pakfire_job_send_log(struct pakfire_job* job, int priority, const char* line, size_t length) {
int r;
+ // Write everything to the log file
+ r = pakfire_log_file_write(job->log.file, priority, line, length);
+ if (r < 0)
+ return r;
+
// Enqueue the line into the buffer
r = pakfire_log_buffer_enqueue(job->log.buffer, priority, line, length);
if (r < 0)
break;
}
- // Send everything but debug messages to the log file
- if (likely(job->log.file))
- pakfire_log_file_write(job->log.file, priority, buffer, length);
-
// Pass everything to the upstream logger
pakfire_ctx_log_condition(job->ctx, priority, "%s", buffer);
}
// Setup logging
pakfire_ctx_set_log_callback(ctx, pakfire_job_log, job);
- // Open a new log file
- r = pakfire_log_file_create(&job->log.file, ctx, NULL, job->id, PAKFIRE_LOG_FILE_COMPRESS);
- if (r < 0) {
- ERROR(ctx, "Could not open log file: %s\n", strerror(-r));
- goto ERROR;
- }
-
// Disable the ccache
if (!pakfire_job_has_flag(job, PAKFIRE_JOB_CCACHE))
build_flags |= PAKFIRE_BUILD_DISABLE_CCACHE;
// Run the build
status = pakfire_build_exec(build, job->pkg, pakfire_job_result, job);
- // Close the log file
- r = pakfire_log_file_close(job->log.file);
- if (r < 0) {
- ERROR(ctx, "Could not close the log file: %s\n", strerror(-r));
- goto ERROR;
- }
-
// Signal that the job has finished
r = pakfire_job_finished(job, status);
if (r < 0)
goto ERROR;
ERROR:
- if (job->log.file)
- pakfire_log_file_unref(job->log.file);
if (build)
pakfire_build_unref(build);
if (ctx)
if (r < 0)
goto ERROR;
+ // Open a new log file
+ r = pakfire_log_file_create(&j->log.file, j->ctx, NULL, j->id, PAKFIRE_LOG_FILE_COMPRESS);
+ if (r < 0) {
+ ERROR(j->ctx, "Could not open log file: %s\n", strerror(-r));
+ goto ERROR;
+ }
+
// Parse the job
r = pakfire_parse_job(j, data);
if (r)