mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:15:43 +01:00
alsactl: redirect alsa-lib errors
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
4bea8fe3a7
commit
8fb4016a17
3 changed files with 19 additions and 0 deletions
|
@ -354,6 +354,8 @@ int main(int argc, char *argv[])
|
|||
syslog(LOG_INFO, "alsactl " SND_UTIL_VERSION_STR " daemon started");
|
||||
}
|
||||
|
||||
snd_lib_error_set_handler(error_handler);
|
||||
|
||||
if (!strcmp(cmd, "init")) {
|
||||
res = init(initfile, cardname);
|
||||
snd_config_update_free_global();
|
||||
|
|
|
@ -11,6 +11,7 @@ void info_(const char *fcn, long line, const char *fmt, ...);
|
|||
void error_(const char *fcn, long line, const char *fmt, ...);
|
||||
void cerror_(const char *fcn, long line, int cond, const char *fmt, ...);
|
||||
void dbg_(const char *fcn, long line, const char *fmt, ...);
|
||||
void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...);
|
||||
|
||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
||||
#define info(...) do { info_(__func__, __LINE__, __VA_ARGS__); } while (0)
|
||||
|
|
|
@ -177,3 +177,19 @@ void dbg_(const char *fcn, long line, const char *fmt, ...)
|
|||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...)
|
||||
{
|
||||
char buf[2048];
|
||||
va_list arg;
|
||||
|
||||
va_start(arg, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, arg);
|
||||
va_end(arg);
|
||||
if (use_syslog)
|
||||
syslog(LOG_ERR, "alsa-lib %s:%i:(%s) %s%s%s\n", file, line, function,
|
||||
buf, err ? ": " : "", err ? snd_strerror(err) : "");
|
||||
else
|
||||
fprintf(stderr, "alsa-lib %s:%i:(%s) %s%s%s\n", file, line, function,
|
||||
buf, err ? ": " : "", err ? snd_strerror(err) : "");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue