There was some code that started implementing this, but weirdly it was
never called...
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
// Store the new logger
self->logger = logger;
// Store the new logger
self->logger = logger;
- Py_INCREF(self->logger);
+ Py_XINCREF(self->logger);
- pakfire_ctx_set_log_callback(self->ctx, Ctx_log_callback, self->logger);
+ if (self->ctx)
+ pakfire_ctx_set_log_callback(self->ctx, Ctx_log_callback, self->logger);
}
static int Ctx_setup_logging(CtxObject* self) {
}
static int Ctx_setup_logging(CtxObject* self) {
// Set default logger
Ctx___set_logger(self, logger);
// Set default logger
Ctx___set_logger(self, logger);
ERROR:
Py_XDECREF(logging);
Py_XDECREF(logger);
ERROR:
Py_XDECREF(logging);
Py_XDECREF(logger);
// Set the log level to DEBUG
pakfire_ctx_set_log_level(self->ctx, LOG_DEBUG);
// Set the log level to DEBUG
pakfire_ctx_set_log_level(self->ctx, LOG_DEBUG);
+ // Setup the default logger
+ r = Ctx_setup_logging(self);
+ if (r)
+ return r;
+
return 0;
}
static void Ctx_dealloc(CtxObject* self) {
return 0;
}
static void Ctx_dealloc(CtxObject* self) {
+ // Reset the logger
+ Ctx___set_logger(self, NULL);
+
if (self->ctx)
pakfire_ctx_unref(self->ctx);
if (self->ctx)
pakfire_ctx_unref(self->ctx);
- Py_XDECREF(self->logger);
-
Py_TYPE(self)->tp_free((PyObject *)self);
}
Py_TYPE(self)->tp_free((PyObject *)self);
}
if (!PyArg_ParseTuple(args, "O", &logger))
return NULL;
if (!PyArg_ParseTuple(args, "O", &logger))
return NULL;
- // XXX Check if we have a log method
-
// Set the logger
Ctx___set_logger(self, logger);
// Set the logger
Ctx___set_logger(self, logger);