|
aubio 0.4.5
|
00001 /* 00002 Copyright (C) 2016 Paul Brossier <piem@aubio.org> 00003 00004 This file is part of aubio. 00005 00006 aubio is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 aubio is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with aubio. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 #ifndef AUBIO_LOG_H 00022 #define AUBIO_LOG_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /** \file 00029 00030 Logging features 00031 00032 This file specifies ::aubio_log_set_function and 00033 ::aubio_log_set_level_function, which let you define one or several custom 00034 logging functions to redirect warnings and errors from aubio to your 00035 application. The custom function should have the prototype defined in 00036 ::aubio_log_function_t. 00037 00038 After a call to ::aubio_log_set_level_function, ::aubio_log_reset can be used 00039 to reset each logging functions to the default ones. 00040 00041 \example utils/test-log.c 00042 00043 */ 00044 00045 /** list of logging levels */ 00046 enum aubio_log_level { 00047 AUBIO_LOG_ERR, /**< critical errors */ 00048 AUBIO_LOG_INF, /**< infos */ 00049 AUBIO_LOG_MSG, /**< general messages */ 00050 AUBIO_LOG_DBG, /**< debug messages */ 00051 AUBIO_LOG_WRN, /**< warnings */ 00052 AUBIO_LOG_LAST_LEVEL, /**< number of valid levels */ 00053 }; 00054 00055 /** Logging function prototype, to be passed to ::aubio_log_set_function 00056 00057 \param level log level 00058 \param message text to log 00059 \param data optional closure used by the callback 00060 00061 See @ref utils/test-log.c for an example of logging function. 00062 00063 */ 00064 typedef void (*aubio_log_function_t)(sint_t level, const char_t *message, void 00065 *data); 00066 00067 /** Set logging function for all levels 00068 00069 \param fun the function to be used to log, of type ::aubio_log_function_t 00070 \param data optional closure to be passed to the function (can be NULL if 00071 nothing to pass) 00072 00073 */ 00074 void aubio_log_set_function(aubio_log_function_t fun, void* data); 00075 00076 /** Set logging function for a given level 00077 00078 \param level the level for which to set the logging function 00079 \param fun the function to be used to log, of type ::aubio_log_function_t 00080 \param data optional closure to be passed to the function (can be NULL if 00081 nothing to pass) 00082 00083 */ 00084 aubio_log_function_t aubio_log_set_level_function(sint_t level, 00085 aubio_log_function_t fun, void* data); 00086 00087 /** Reset all logging functions to the default one 00088 00089 After calling this function, the default logging function will be used to 00090 print error, warning, normal, and debug messages to `stdout` or `stderr`. 00091 00092 */ 00093 void aubio_log_reset(void); 00094 00095 #ifdef __cplusplus 00096 } 00097 #endif 00098 00099 #endif /* AUBIO_LOG_H */
1.7.3