gst/: We now have debugging in gst-python ;) gst.[log|debug|info|warning|error]()

Original commit message from CVS:
* gst/gst.defs:
* gst/gst.override:
* gst/gstmodule.c:
We now have debugging in gst-python ;)
gst.[log|debug|info|warning|error]()
This commit is contained in:
Edward Hervey 2005-08-04 10:44:16 +00:00
parent 0f04024f5c
commit 139163d89e
4 changed files with 114 additions and 0 deletions

View file

@ -1,3 +1,11 @@
2005-08-04 Edward Hervey <edward@fluendo.com>
* gst/gst.defs:
* gst/gst.override:
* gst/gstmodule.c:
We now have debugging in gst-python ;)
gst.[log|debug|info|warning|error]()
2005-08-03 Edward Hervey <edward@fluendo.com> 2005-08-03 Edward Hervey <edward@fluendo.com>
* configure.ac: * configure.ac:

View file

@ -2273,7 +2273,48 @@
) )
) )
;; DEBUGGING FUNCTIONS FROM PYTHON
;; The c functions don't actually exist
(define-function log
(c-name "gst_log")
(return-type "none")
(parameters
'("gchar *" "msg")
)
)
(define-function debug
(c-name "gst_debug")
(return-type "none")
(parameters
'("gchar *" "msg")
)
)
(define-function info
(c-name "gst_info")
(return-type "none")
(parameters
'("gchar *" "msg")
)
)
(define-function warning
(c-name "gst_warning")
(return-type "none")
(parameters
'("gchar *" "msg")
)
)
(define-function error
(c-name "gst_error")
(return-type "none")
(parameters
'("gchar *" "msg")
)
)
;; From ../gstreamer/gst/gstinterface.h ;; From ../gstreamer/gst/gstinterface.h

View file

@ -53,6 +53,9 @@ headers
PyObject *PyGstExc_LinkError = NULL; PyObject *PyGstExc_LinkError = NULL;
GST_DEBUG_CATEGORY_EXTERN (gst_python);
#define GST_CAT_DEFAULT gst_python
GSList *mainloops = NULL; GSList *mainloops = NULL;
void void
_pygst_main_quit(void) _pygst_main_quit(void)
@ -217,6 +220,30 @@ _pygst_element_init (gpointer gclass, PyTypeObject *pyclass)
} }
#endif #endif
static PyObject *
pygst_debug_log (PyObject *whatever, PyObject *string, GstDebugLevel level)
{
gchar *str;
gchar *function;
gchar *filename;
gchar lineno;
PyFrameObject *frame;
if (!PyArg_ParseTuple(string, "s:gst.debug_log", &str)) {
PyErr_SetString(PyExc_TypeError, "Need a string!");
return NULL;
}
frame = PyEval_GetFrame();
function = PyString_AsString(frame->f_code->co_name);
filename = PyString_AsString(frame->f_code->co_filename);
lineno = frame->f_code->co_firstlineno;
/* gst_debug_log : category, level, file, function, line, object, format, va_list */
gst_debug_log (GST_CAT_DEFAULT, level, filename, function, lineno, NULL, str);
Py_INCREF (Py_None);
return Py_None;
}
%% %%
include include
gstbin.override gstbin.override
@ -959,3 +986,38 @@ _wrap_gst_flow_get_name(PyObject *self, PyObject *args, PyObject *kwargs)
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
%%
override gst_log args
static PyObject *
_wrap_gst_log (PyObject *whatever, PyObject *string)
{
return pygst_debug_log (whatever, string, GST_LEVEL_LOG);
}
%%
override gst_debug args
static PyObject *
_wrap_gst_debug (PyObject *whatever, PyObject *string)
{
return pygst_debug_log (whatever, string, GST_LEVEL_DEBUG);
}
%%
override gst_info args
static PyObject *
_wrap_gst_info (PyObject *whatever, PyObject *string)
{
return pygst_debug_log (whatever, string, GST_LEVEL_INFO);
}
%%
override gst_warning
static PyObject *
_wrap_gst_warning (PyObject *whatever, PyObject *string)
{
return pygst_debug_log (whatever, string, GST_LEVEL_WARNING);
}
%%
override gst_error
static PyObject *
_wrap_gst_error (PyObject *whatever, PyObject *string)
{
return pygst_debug_log (whatever, string, GST_LEVEL_ERROR);
}

View file

@ -42,6 +42,7 @@ extern GSList *mainloops;
extern void _pygst_main_quit(void); extern void _pygst_main_quit(void);
extern PyObject *PyGstExc_LinkError; extern PyObject *PyGstExc_LinkError;
GST_DEBUG_CATEGORY (gst_python);
/* This is a timeout that gets added to the mainloop to handle SIGINT (Ctrl-C) /* This is a timeout that gets added to the mainloop to handle SIGINT (Ctrl-C)
* Other signals get handled at some other point where transition from * Other signals get handled at some other point where transition from
@ -168,6 +169,8 @@ init_gst (void)
pygst_register_classes (d); pygst_register_classes (d);
pygst_add_constants (m, "GST_"); pygst_add_constants (m, "GST_");
/* Initialize debugging category */
GST_DEBUG_CATEGORY_INIT (gst_python, "gst-python", 0, "GStreamer python bindings");
g_timeout_add_full (0, 100, python_do_pending_calls, NULL, NULL); g_timeout_add_full (0, 100, python_do_pending_calls, NULL, NULL);