3 #include "aubio_priv.h"
5 const char_t *hdr = "CUSTOM HEADER: ";
6 const char_t *hdr2 = "OTHER HEADER: ";
8 /* an example of logging function that adds a custom header and prints
9 * aubio debug messages on stdout instead of stderr */
10 void logging(int level, const char_t *message, void *data) {
12 //fprintf(stdout, "using custom logging function\n");
13 if (level == AUBIO_LOG_ERR) {
18 if ((level >= 0) && (data != NULL)) {
19 fprintf(out, "%s", (const char_t *)data);
21 fprintf(out, "%s", message);
26 fprintf(stdout, "### testing normal logging\n");
27 AUBIO_ERR("testing normal AUBIO_LOG_ERR\n");
28 AUBIO_INF("testing normal AUBIO_LOG_INF\n");
29 AUBIO_WRN("testing normal AUBIO_LOG_WRN\n");
30 AUBIO_MSG("testing normal AUBIO_LOG_MSG\n");
31 AUBIO_DBG("testing normal AUBIO_LOG_DBG\n");
33 fprintf(stdout, "### testing with one custom function\n");
34 aubio_log_set_function(logging, (void *)hdr);
35 AUBIO_ERR("testing custom set_function AUBIO_LOG_ERR\n");
36 AUBIO_INF("testing custom set_function AUBIO_LOG_INF\n");
37 AUBIO_WRN("testing custom set_function AUBIO_LOG_WRN\n");
38 AUBIO_MSG("testing custom set_function AUBIO_LOG_MSG\n");
39 AUBIO_DBG("testing custom set_function AUBIO_LOG_DBG\n");
41 fprintf(stdout, "### testing resetted logging\n");
43 AUBIO_ERR("testing again normal AUBIO_LOG_ERR\n");
44 AUBIO_INF("testing again normal AUBIO_LOG_INF\n");
45 AUBIO_WRN("testing again normal AUBIO_LOG_WRN\n");
46 AUBIO_MSG("testing again normal AUBIO_LOG_MSG\n");
47 AUBIO_DBG("testing again normal AUBIO_LOG_DBG\n");
49 fprintf(stdout, "### testing per level customization\n");
50 aubio_log_set_level_function(AUBIO_LOG_ERR, logging, (void *)hdr2);
51 aubio_log_set_level_function(AUBIO_LOG_WRN, logging, NULL);
52 aubio_log_set_level_function(AUBIO_LOG_MSG, logging, (void *)hdr);
53 AUBIO_ERR("testing custom set_level_function AUBIO_LOG_ERR\n");
54 AUBIO_INF("testing again normal AUBIO_LOG_INF\n");
55 AUBIO_WRN("testing custom set_level_function AUBIO_LOG_WRN with data=NULL\n");
56 AUBIO_MSG("testing custom set_level_function AUBIO_LOG_MSG\n");
57 AUBIO_DBG("testing again normal AUBIO_LOG_DBG\n");