log: implement filter based on string configuration (env LIBASOUND_DEBUG).

Examples:

 "debug"                 - Set global level to debug
 "3"                     - Set global level to 3 (info)
 "info,pcm:debug"        - Set global to info, pcm to debug
 "error,mixer:5,pcm:4"   - Set global to error, mixer to 5 (trace), pcm to 4 (debug)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2025-11-07 12:18:00 +01:00
parent 524081b4d6
commit b37ac0982b
3 changed files with 158 additions and 0 deletions

View file

@ -86,6 +86,7 @@ const char *snd_strerror(int errnum);
*/
typedef void (*snd_lib_log_handler_t)(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg);
extern snd_lib_log_handler_t snd_lib_vlog;
int snd_lib_log_filter(int prio, int interface, const char *configstr);
void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 7, 8))) */;
void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...);
snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler);