]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Remove logging stuff in favour of the context
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Oct 2023 10:09:12 +0000 (10:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Oct 2023 10:09:12 +0000 (10:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/include/pakfire/logging.h
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/libpakfire.sym
src/libpakfire/pakfire.c

index f9a1e9cf490f7081dcecb22f397226dbfc76d43b..680c955a9c056c0c0fed7ee6e5c553c4a3f2f68c 100644 (file)
@@ -49,14 +49,9 @@ extern struct pakfire_ctx* pakfire_ctx;
 
 static PyObject* Pakfire_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
        PakfireObject* self = (PakfireObject *)type->tp_alloc(type, 0);
-       if (self) {
+       if (self)
                self->pakfire = NULL;
 
-               // Callbacks
-               self->callbacks.log = NULL;
-               self->callbacks.confirm = NULL;
-       }
-
        return (PyObject *)self;
 }
 
@@ -277,12 +272,6 @@ ERROR:
 
 static void Pakfire_dealloc(PakfireObject* self) {
        if (self->pakfire) {
-               // Reset log callback
-               if (self->callbacks.log) {
-                       pakfire_set_log_callback(self->pakfire, NULL, NULL);
-                       Py_DECREF(self->callbacks.log);
-               }
-
                // Reset confirm callback
                if (self->callbacks.confirm) {
                        pakfire_set_confirm_callback(self->pakfire, NULL, NULL);
index 5193a259d21b0dae02fc639df5ef736c046b55e0..0fe1b7dcd604296d30910509a1c39408541e7bde 100644 (file)
@@ -64,10 +64,7 @@ static inline void __attribute__((always_inline, format(printf, 2, 3)))
        pakfire_log_null(struct pakfire* pakfire, const char *format, ...) {}
 
 #define pakfire_log_condition(pakfire, prio, r, arg...) \
-       do { \
-               if (pakfire_log_get_priority(pakfire) >= prio) \
-                       pakfire_log(pakfire, prio, r, __FILE__, __LINE__, __FUNCTION__, ## arg); \
-       } while (0)
+       pakfire_log(pakfire, prio, r, __FILE__, __LINE__, __FUNCTION__, ## arg)
 
 #define INFO(pakfire, arg...) pakfire_log_condition(pakfire, LOG_INFO, 0, ## arg)
 #define ERROR(pakfire, arg...) pakfire_log_condition(pakfire, LOG_ERR, 0, ## arg)
index 71dca90a90476b6324e57f5c53420a01fc211032..eed9784044b469a44c2707fcc7b1026c760867a9 100644 (file)
@@ -47,8 +47,6 @@ enum pakfire_flags {
 };
 
 // Callbacks
-void pakfire_set_log_callback(struct pakfire* pakfire,
-       pakfire_log_callback callback, void* data);
 typedef int (*pakfire_confirm_callback)(struct pakfire* pakfire, void* data,
        const char* message, const char* question);
 void pakfire_set_confirm_callback(struct pakfire* pakfire,
@@ -104,11 +102,6 @@ enum pakfire_search_flags {
 int pakfire_search(struct pakfire* pakfire, const char* what, int flags,
        struct pakfire_packagelist* list);
 
-// Logging
-
-int pakfire_log_get_priority(struct pakfire* pakfire);
-void pakfire_log_set_priority(struct pakfire* pakfire, int priority);
-
 // Check
 
 int pakfire_check(struct pakfire* pakfire, struct pakfire_filelist* errors);
index c221aabb0263d49ffc68eb41489c425b24304a8c..a57458d3aa3cafdad628a80e0a4ff7d51bbaeff9 100644 (file)
@@ -41,7 +41,6 @@ global:
        pakfire_refresh;
        pakfire_search;
        pakfire_set_confirm_callback;
-       pakfire_set_log_callback;
        pakfire_set_pick_solution_callback;
        pakfire_set_setup_progress_callback;
        pakfire_unref;
@@ -164,9 +163,6 @@ global:
        pakfire_jail_unref;
 
        # log
-       pakfire_log_get_priority;
-       pakfire_log_set_function;
-       pakfire_log_set_priority;
        pakfire_log_stderr;
        pakfire_log_syslog;
 
index 4223cece3b97e3721f0b3682f8a39f4f54084355..7c01877dc515839a6997ea075ec37f3a8ccd60ff 100644 (file)
@@ -103,10 +103,6 @@ struct pakfire {
 
        // Callbacks
        struct pakfire_callbacks {
-               // Logging
-               pakfire_log_callback log;
-               void* log_data;
-
                // Confirm
                pakfire_confirm_callback confirm;
                void* confirm_data;
@@ -238,25 +234,6 @@ static unsigned int pakfire_unmap_id(struct pakfire* pakfire,
        return unmapped_id;
 }
 
-static int log_priority(const char* priority) {
-       char* end;
-
-       int prio = strtol(priority, &end, 10);
-       if (*end == '\0' || isspace(*end))
-               return prio;
-
-       if (strncmp(priority, "error", strlen("error")) == 0)
-               return LOG_ERR;
-
-       if (strncmp(priority, "info", strlen("info")) == 0)
-               return LOG_INFO;
-
-       if (strncmp(priority, "debug", strlen("debug")) == 0)
-               return LOG_DEBUG;
-
-       return 0;
-}
-
 static void pool_log(Pool* pool, void* data, int type, const char* s) {
        struct pakfire* pakfire = (struct pakfire*)data;
 
@@ -903,7 +880,6 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, struct pakfire_ctx*
                pakfire_log_callback log_callback, void* log_data) {
        char tempdir[PATH_MAX] = PAKFIRE_TMP_DIR "/pakfire-root-XXXXXX";
        char private_dir[PATH_MAX];
-       const char* env = NULL;
        int r = 1;
 
        // Reset pakfire pointer
@@ -923,25 +899,6 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, struct pakfire_ctx*
        p->nrefs = 1;
        p->flags = flags;
 
-       // Setup logging
-       if (log_callback)
-               pakfire_set_log_callback(p, log_callback, log_data);
-       else
-               pakfire_set_log_callback(p, pakfire_log_syslog, NULL);
-
-       // 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 if ((env = secure_getenv("PAKFIRE_LOG"))) {
-               pakfire_log_set_priority(p, log_priority(env));
-
-       // Otherwise set the log level to INFO
-       } else {
-               pakfire_log_set_priority(p, LOG_INFO);
-       }
-
        // Store the nominal architecture
        r = pakfire_string_set(p->arches.nominal, arch);
        if (r)
@@ -1672,20 +1629,6 @@ PAKFIRE_EXPORT int pakfire_search(struct pakfire* pakfire, const char* what, int
 
 // Logging
 
-PAKFIRE_EXPORT int pakfire_log_get_priority(struct pakfire* pakfire) {
-       return pakfire->log_priority;
-}
-
-PAKFIRE_EXPORT void pakfire_log_set_priority(struct pakfire* pakfire, int priority) {
-       pakfire->log_priority = priority;
-}
-
-PAKFIRE_EXPORT void pakfire_set_log_callback(struct pakfire* pakfire,
-               pakfire_log_callback callback, void* data) {
-       pakfire->callbacks.log = callback;
-       pakfire->callbacks.log_data = data;
-}
-
 // XXX This function is deprecated and needs to be removed
 void pakfire_log(struct pakfire* pakfire, int priority, int r,
                const char* file, int line, const char* fn, const char* format, ...) {