History

python/ext/aubiomodule.c: use custom logging function for errors and warnings

Paul Brossier committed 10 years ago

Commit 67537d71 parent aa5828d1 file · +18 −0Browse files

Showing the changes to python/ext (1 of 1 file). Show all

Unified · Split

python/ext/aubiomodule.c+18−0
@@ -256,6 +256,22 @@ static struct PyModuleDef moduledef = { · 255 unmodified lines
256};256};
257#endif257#endif
258 258
259void
260aubio_log_function(int level, const char *message, void *data)
261{
262 // remove trailing \n
263 char *pos;
264 if ((pos=strchr(message, '\n')) != NULL) {
265 *pos = '\0';
266 }
267 // warning or error
268 if (level == AUBIO_LOG_ERR) {
269 PyErr_Format(PyExc_RuntimeError, "%s", message);
270 } else {
271 PyErr_WarnEx(PyExc_UserWarning, message, 1);
272 }
273}
274
259static PyObject *275static PyObject *
260initaubio (void)276initaubio (void)
261{277{
@@ -315,6 +331,8 @@ initaubio (void) · 53 unmodified lines
315 // add ufunc331 // add ufunc
316 add_ufuncs(m);332 add_ufuncs(m);
317 333
334 aubio_log_set_level_function(AUBIO_LOG_ERR, aubio_log_function, NULL);
335 aubio_log_set_level_function(AUBIO_LOG_WRN, aubio_log_function, NULL);
318 return m;336 return m;
319}337}
320 338

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t