goto ERROR;
}
- int flags = 0;
+ int flags = PAKFIRE_FLAGS_DEBUG;
// Enable offline mode
if (offline)
// Create a new Pakfire instance
r = pakfire_create(&self->pakfire, path, arch, fconf, flags,
- LOG_DEBUG, Pakfire_log_callback, self->callbacks.log);
+ Pakfire_log_callback, self->callbacks.log);
Py_END_ALLOW_THREADS
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/syslog.h>
#include <unistd.h>
#include <pakfire/pakfire.h>
char* arch;
char* root;
int flags;
- int loglevel;
int yes;
// Repos
break;
case ARG_DEBUG:
- config->loglevel = LOG_DEBUG;
+ config->flags |= PAKFIRE_FLAGS_DEBUG;
break;
case ARG_OFFLINE:
.arch = NULL,
.root = "/",
.flags = 0,
- .loglevel = LOG_INFO,
.yes = 0,
};
// Initialize Pakfire
r = pakfire_create(&pakfire, config.root, config.arch, f,
- config.flags, config.loglevel, NULL, NULL);
+ config.flags, NULL, NULL);
if (r)
goto ERROR;
#include <pakfire/transaction.h>
enum pakfire_flags {
- PAKFIRE_FLAGS_OFFLINE = (1 << 0),
+ PAKFIRE_FLAGS_DEBUG = (1 << 0),
+ PAKFIRE_FLAGS_OFFLINE = (1 << 1),
};
// Callbacks
int progress, const char* status);
int pakfire_create(struct pakfire** pakfire, const char* path, const char* arch,
- FILE* conf, int flags, int loglevel, pakfire_log_callback log_callback, void* log_data);
+ FILE* conf, int flags, pakfire_log_callback log_callback, void* log_data);
struct pakfire* pakfire_ref(struct pakfire* pakfire);
struct pakfire* pakfire_unref(struct pakfire* pakfire);
}
PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
- const char* arch, FILE* conf, int flags,
- int loglevel, pakfire_log_callback log_callback, void* log_data) {
+ const char* arch, FILE* conf, int flags, pakfire_log_callback log_callback, void* log_data) {
char tempdir[PATH_MAX] = PAKFIRE_TMP_DIR "/pakfire-root-XXXXXX";
char private_dir[PATH_MAX];
int r = 1;
else
pakfire_set_log_callback(p, pakfire_log_syslog, NULL);
- // Set log level
- if (loglevel) {
- pakfire_log_set_priority(p, loglevel);
+ // Set log level to debug if in debug mode
+ if (pakfire_has_flag(p, PAKFIRE_FLAGS_DEBUG)) {
+ pakfire_log_set_priority(p, LOG_DEBUG);
+
+ // Otherwise take the log level from the environment
} else {
const char* env = secure_getenv("PAKFIRE_LOG");
if (env)
// Create a pakfire instance
r = pakfire_create(&pakfire, root, NULL, NULL,
- 0, LOG_DEBUG, pakfire_log_stderr, NULL);
+ PAKFIRE_FLAGS_DEBUG, pakfire_log_stderr, NULL);
if (r) {
fprintf(stderr, "Could not create Pakfire: %m\n");
goto ERROR;
static int test_run(int i, struct test* t) {
struct pakfire* p = NULL;
FILE* c = NULL;
+ const int flags = PAKFIRE_FLAGS_DEBUG;
char root[PATH_MAX] = TEST_ROOTFS "/pakfire-test-XXXXXX";
int r;
}
// Create a pakfire instance
- r = pakfire_create(&t->pakfire, root, NULL, c, 0, LOG_DEBUG, pakfire_log_stderr, NULL);
+ r = pakfire_create(&t->pakfire, root, NULL, c, flags, pakfire_log_stderr, NULL);
if (r) {
LOG("ERROR: Could not initialize pakfire: %m\n");
goto ERROR;