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/pacman/callback.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/pacman/callback.c') diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 1d68db4c..4993382d 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -281,24 +281,6 @@ void cb_event(alpm_event_t *event) event->database_missing.dbname); } break; - case ALPM_EVENT_LOG: - { - alpm_event_log_t *e = &event->log; - if(!e->fmt || strlen(e->fmt) == 0) { - break; - } - - if(on_progress) { - char *string = NULL; - pm_vasprintf(&string, e->level, e->fmt, e->args); - if(string != NULL) { - output = alpm_list_add(output, string); - } - } else { - pm_vfprintf(stderr, e->level, e->fmt, e->args); - } - } - break; case ALPM_EVENT_PACNEW_CREATED: { alpm_event_pacnew_created_t *e = &event->pacnew_created; @@ -862,4 +844,22 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) return; } +/* Callback to handle notifications from the library */ +void cb_log(alpm_loglevel_t level, const char *fmt, va_list args) +{ + if(!fmt || strlen(fmt) == 0) { + return; + } + + if(on_progress) { + char *string = NULL; + pm_vasprintf(&string, level, fmt, args); + if(string != NULL) { + output = alpm_list_add(output, string); + } + } else { + pm_vfprintf(stderr, level, fmt, args); + } +} + /* vim: set noet: */ -- cgit v1.2.3-24-g4f1b