]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
pakfire: Pass loglevel on creation
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 17:26:43 +0000 (17:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 17:26:43 +0000 (17:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/pakfire.c
tests/testsuite.c

index 71f775c9fa3951fcc4585acde52556f922780cc8..b9b3eb3beee8b1ec45d64309e993a9b1b01fd4e9 100644 (file)
@@ -199,7 +199,7 @@ static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
 
        // Create a new Pakfire instance
        int r = pakfire_create(&self->pakfire, path, arch, conf, flags,
-               Pakfire_log_callback, self->callbacks.log);
+               LOG_DEBUG, Pakfire_log_callback, self->callbacks.log);
        if (r) {
                switch (errno) {
                        // Invalid architecture or path
index c971c49e296f3ec7dd382c20db7f53e89d58f5aa..392a878193221e2bbfba06bd9ee24a7db13d3d21 100644 (file)
@@ -64,7 +64,8 @@ typedef void (*pakfire_status_callback)(struct pakfire* pakfire, void* data,
        int progress, const char* status);
 
 int pakfire_create(struct pakfire** pakfire, const char* path, const char* arch,
-       const char* conf, int flags, pakfire_log_callback log_callback, void* log_data);
+       const char* conf, int flags,
+       int loglevel, pakfire_log_callback log_callback, void* log_data);
 
 struct pakfire* pakfire_ref(struct pakfire* pakfire);
 struct pakfire* pakfire_unref(struct pakfire* pakfire);
index 3cd962fee8ed05d7565f4c02f59fc44b6ebfa9c3..9d3dd50e8eea6a15481209ea62739e86dca28743 100644 (file)
@@ -697,7 +697,7 @@ ERROR:
 
 PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
                const char* arch, const char* conf, int flags,
-               pakfire_log_callback log_callback, void* log_data) {
+               int loglevel, pakfire_log_callback log_callback, void* log_data) {
        char tempdir[PATH_MAX] = PAKFIRE_TMP_DIR "/XXXXXX";
        int r = 1;
 
@@ -743,9 +743,14 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
        else
                pakfire_set_log_callback(p, pakfire_log_syslog, NULL);
 
-       const char* env = secure_getenv("PAKFIRE_LOG");
-       if (env)
-               pakfire_log_set_priority(p, log_priority(env));
+       // Set log level
+       if (loglevel) {
+               pakfire_log_set_priority(p, loglevel);
+       } else {
+               const char* env = secure_getenv("PAKFIRE_LOG");
+               if (env)
+                       pakfire_log_set_priority(p, log_priority(env));
+       }
 
        // Setup confirm callback
        pakfire_set_confirm_callback(p, pakfire_ui_confirm, NULL);
index 82bfb8beb9ccb064664e7416cdd252b705801ccc..5da2cef9964793fa872dc89c17746adab1e3a187 100644 (file)
@@ -48,15 +48,12 @@ static int test_run(int i, struct test* t) {
 
        // Create a pakfire instance
        r = pakfire_create(&t->pakfire, root, NULL, TEST_SRC_PATH "/pakfire.conf",
-               0, pakfire_log_stderr, NULL);
+               0, LOG_DEBUG, pakfire_log_stderr, NULL);
        if (r) {
                LOG("ERROR: Could not initialize pakfire: %m\n");
                exit(1);
        }
 
-       // Enable debug logging
-       pakfire_log_set_priority(t->pakfire, LOG_DEBUG);
-
        r = t->func(t);
        if (r)
                LOG("Test failed with error code: %d\n", r);