From cd793c5ab7689cc8cbc18277375b368060e5acfe Mon Sep 17 00:00:00 2001 From: Olivier Brunel Date: Fri, 10 Jan 2014 16:25:15 +0100 Subject: Remove log_cb, add ALPM_EVENT_LOG instead When ALPM emits a log message, it still goes through _alpm_log() but instead of calling a specific log callback, it goes as an event. Signed-off-by: Olivier Brunel Signed-off-by: Allan McRae --- src/util/cleanupdelta.c | 14 ++++++++------ src/util/testdb.c | 14 ++++++++------ src/util/testpkg.c | 14 ++++++++------ 3 files changed, 24 insertions(+), 18 deletions(-) (limited to 'src/util') diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index 4a67fc38..190e2c70 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -35,17 +35,19 @@ static void cleanup(int signum) exit(signum); } -__attribute__((format(printf, 2, 0))) -static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args) +static void output_cb(alpm_event_log_t *event) { - if(strlen(fmt)) { - switch(level) { + if(event->type != ALPM_EVENT_LOG) { + return; + } + if(strlen(event->fmt)) { + switch(event->level) { case ALPM_LOG_ERROR: printf("error: "); break; case ALPM_LOG_WARNING: printf("warning: "); break; /* case ALPM_LOG_DEBUG: printf("debug: "); break; */ default: return; } - vprintf(fmt, args); + vprintf(event->fmt, event->args); } } @@ -126,7 +128,7 @@ int main(int argc, char *argv[]) } /* let us get log messages from libalpm */ - alpm_option_set_logcb(handle, output_cb); + alpm_option_set_eventcb(handle, (alpm_cb_event) output_cb); checkdbs(dbnames); alpm_list_free(dbnames); diff --git a/src/util/testdb.c b/src/util/testdb.c index e3b331ab..4d1fd4c8 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -39,16 +39,18 @@ static void cleanup(int signum) exit(signum); } -__attribute__((format(printf, 2, 0))) -static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args) +static void output_cb(alpm_event_log_t *event) { - if(strlen(fmt)) { - switch(level) { + if(event->type != ALPM_EVENT_LOG) { + return; + } + if(strlen(event->fmt)) { + switch(event->level) { case ALPM_LOG_ERROR: printf("error: "); break; case ALPM_LOG_WARNING: printf("warning: "); break; default: return; } - vprintf(fmt, args); + vprintf(event->fmt, event->args); } } @@ -282,7 +284,7 @@ int main(int argc, char *argv[]) } /* let us get log messages from libalpm */ - alpm_option_set_logcb(handle, output_cb); + alpm_option_set_eventcb(handle, (alpm_cb_event) output_cb); if(!dbnames) { errors = check_localdb(); diff --git a/src/util/testpkg.c b/src/util/testpkg.c index cc7d9c2b..39807feb 100644 --- a/src/util/testpkg.c +++ b/src/util/testpkg.c @@ -23,18 +23,20 @@ #include -__attribute__((format(printf, 2, 0))) -static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args) +static void output_cb(alpm_event_log_t *event) { - if(fmt[0] == '\0') { + if(event->type != ALPM_EVENT_LOG) { return; } - switch(level) { + if(event->fmt[0] == '\0') { + return; + } + switch(event->level) { case ALPM_LOG_ERROR: printf("error: "); break; case ALPM_LOG_WARNING: printf("warning: "); break; default: return; /* skip other messages */ } - vprintf(fmt, args); + vprintf(event->fmt, event->args); } int main(int argc, char *argv[]) @@ -59,7 +61,7 @@ int main(int argc, char *argv[]) } /* let us get log messages from libalpm */ - alpm_option_set_logcb(handle, output_cb); + alpm_option_set_eventcb(handle, (alpm_cb_event) output_cb); /* set gpgdir to default */ alpm_option_set_gpgdir(handle, GPGDIR); -- cgit v1.2.3-24-g4f1b