*/
static int pakfire_jail_default_log_callback(struct pakfire* pakfire, void* data,
int priority, const char* line, size_t length) {
- switch (priority) {
- case LOG_INFO:
- INFO(pakfire, "%.*s", (int)length, line);
- break;
+ struct pakfire_ctx* ctx = pakfire_ctx(pakfire);
- case LOG_ERR:
- ERROR(pakfire, "%.*s", (int)length, line);
- break;
+ if (pakfire_ctx_get_log_level(ctx) >= priority)
+ pakfire_ctx_log(ctx, priority, NULL, 0, NULL, "%.*s", (int)length, line);
-#ifdef ENABLE_DEBUG
- case LOG_DEBUG:
- DEBUG(pakfire, "%.*s", (int)length, line);
- break;
-#endif
- }
+ pakfire_ctx_unref(ctx);
return 0;
}
return;
}
+ // End if we do not have a file descriptor to write to
+ if (fd < 0)
+ return;
+
+ // Optionally log the function name
+ if (fn)
+ dprintf(fd, "%s: ", fn);
+
// Send the log message
- if (fd >= 0)
- vdprintf(fd, format, args);
+ vdprintf(fd, format, args);
}
static int pakfire_jail_log_buffer_is_full(const struct pakfire_log_buffer* buffer) {