#include <syslog.h>
#include <pakfire/ctx.h>
+#include <pakfire/logging.h>
#include <pakfire/private.h>
struct pakfire_ctx {
// Logging
struct pakfire_ctx_log {
int level;
+
+ // Callback
+ pakfire_log_callback callback;
+ void* data;
} log;
};
// Store the log level
pakfire_ctx_set_log_level(ctx, level);
+ // Log to syslog by default
+ pakfire_ctx_set_log_callback(ctx, pakfire_log_syslog, NULL);
+
return 0;
}
PAKFIRE_EXPORT void pakfire_ctx_set_log_level(struct pakfire_ctx* ctx, int level) {
ctx->log.level = level;
}
+
+PAKFIRE_EXPORT void pakfire_ctx_set_log_callback(struct pakfire_ctx* ctx,
+ pakfire_log_callback callback, void* data) {
+ ctx->log.callback = callback;
+ ctx->log.data = data;
+}
struct pakfire_ctx;
+#include <pakfire/logging.h>
+
int pakfire_ctx_create(struct pakfire_ctx** ctx);
struct pakfire_ctx* pakfire_ctx_ref(struct pakfire_ctx* ctx);
int pakfire_ctx_get_log_level(struct pakfire_ctx* ctx);
void pakfire_ctx_set_log_level(struct pakfire_ctx* ctx, int level);
+void pakfire_ctx_set_log_callback(struct pakfire_ctx* ctx,
+ pakfire_log_callback callback, void* data);
+
#endif /* PAKFIRE_CTX_H */
#ifndef PAKFIRE_LOGGING_H
#define PAKFIRE_LOGGING_H
+#include <stdarg.h>
#include <syslog.h>
+typedef void (*pakfire_log_callback)(void* data, int priority, const char* file,
+ int line, const char* fn, const char* format, va_list args);
+
#include <pakfire/pakfire.h>
void pakfire_log_stderr(void* data, int priority, const char* file,
#include <pakfire/ctx.h>
#include <pakfire/filelist.h>
#include <pakfire/key.h>
+#include <pakfire/logging.h>
#include <pakfire/packagelist.h>
#include <pakfire/parser.h>
#include <pakfire/progress.h>
};
// Callbacks
-typedef void (*pakfire_log_callback)(void* data, int priority, const char* file,
- int line, const char* fn, const char* format, va_list args);
void pakfire_set_log_callback(struct pakfire* pakfire,
pakfire_log_callback callback, void* data);
typedef int (*pakfire_confirm_callback)(struct pakfire* pakfire, void* data,
pakfire_ctx_unref;
pakfire_ctx_get_log_level;
pakfire_ctx_set_log_level;
+ pakfire_ctx_set_log_callback;
# pakfire
pakfire_check;
// Set the log level to DEBUG
pakfire_ctx_set_log_level(ctx, LOG_DEBUG);
+ // Log everything to the console
+ pakfire_ctx_set_log_callback(ctx, pakfire_log_stderr, NULL);
+
// Create a pakfire instance
r = pakfire_create(&pakfire, ctx, root, NULL, NULL,
PAKFIRE_FLAGS_DEBUG, pakfire_log_stderr, NULL);
// Set the log level to DEBUG
pakfire_ctx_set_log_level(ctx, LOG_DEBUG);
+ // Log everything to the console
+ pakfire_ctx_set_log_callback(ctx, pakfire_log_stderr, NULL);
+
// Open the configuration file
c = fopen(TEST_SRC_PATH "/pakfire.conf", "r");
if (!c) {