From b52ed49d75ff77ef4f6ad2bef576184bda9b98d0 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sun, 28 Sep 2014 17:45:35 -0400 Subject: Revert "Remove log_cb, add ALPM_EVENT_LOG instead" Moving logging to the event callback caused warnings under clang due to non-literal format strings and silenced all log messages when --print was used. This reverts commit cd793c5ab7689cc8cbc18277375b368060e5acfe. Signed-off-by: Andrew Gregory Conflicts: lib/libalpm/alpm.h src/pacman/callback.c Signed-off-by: Allan McRae --- src/util/testdb.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/util/testdb.c') diff --git a/src/util/testdb.c b/src/util/testdb.c index 4d1fd4c8..e3b331ab 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -39,18 +39,16 @@ static void cleanup(int signum) exit(signum); } -static void output_cb(alpm_event_log_t *event) +__attribute__((format(printf, 2, 0))) +static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args) { - if(event->type != ALPM_EVENT_LOG) { - return; - } - if(strlen(event->fmt)) { - switch(event->level) { + if(strlen(fmt)) { + switch(level) { case ALPM_LOG_ERROR: printf("error: "); break; case ALPM_LOG_WARNING: printf("warning: "); break; default: return; } - vprintf(event->fmt, event->args); + vprintf(fmt, args); } } @@ -284,7 +282,7 @@ int main(int argc, char *argv[]) } /* let us get log messages from libalpm */ - alpm_option_set_eventcb(handle, (alpm_cb_event) output_cb); + alpm_option_set_logcb(handle, output_cb); if(!dbnames) { errors = check_localdb(); -- cgit v1.2.3-24-g4f1b