Changeset 67537d7


Ignore:
Timestamp:
Sep 22, 2016, 10:55:47 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
d45f527
Parents:
aa5828d
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/aubiomodule.c

    raa5828d r67537d7  
    257257#endif
    258258
     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
    259275static PyObject *
    260276initaubio (void)
     
    316332  add_ufuncs(m);
    317333
     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);
    318336  return m;
    319337}
Note: See TracChangeset for help on using the changeset viewer.