summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-09-28 23:45:35 +0200
committerAllan McRae <allan@archlinux.org>2014-09-30 04:56:21 +0200
commitb52ed49d75ff77ef4f6ad2bef576184bda9b98d0 (patch)
treeb4c7f71acf22f05302ebaf76967f18521a713275 /src/util
parent31b98626003fec9e33483152552906a601c072d4 (diff)
downloadpacman-b52ed49d75ff77ef4f6ad2bef576184bda9b98d0.tar.gz
pacman-b52ed49d75ff77ef4f6ad2bef576184bda9b98d0.tar.xz
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 <andrew.gregory.8@gmail.com> Conflicts: lib/libalpm/alpm.h src/pacman/callback.c Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/cleanupdelta.c14
-rw-r--r--src/util/testdb.c14
-rw-r--r--src/util/testpkg.c14
3 files changed, 18 insertions, 24 deletions
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 190e2c70..4a67fc38 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -35,19 +35,17 @@ 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;
/* case ALPM_LOG_DEBUG: printf("debug: "); break; */
default: return;
}
- vprintf(event->fmt, event->args);
+ vprintf(fmt, args);
}
}
@@ -128,7 +126,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);
checkdbs(dbnames);
alpm_list_free(dbnames);
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();
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 39807feb..cc7d9c2b 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -23,20 +23,18 @@
#include <alpm.h>
-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) {
+ if(fmt[0] == '\0') {
return;
}
- if(event->fmt[0] == '\0') {
- return;
- }
- switch(event->level) {
+ switch(level) {
case ALPM_LOG_ERROR: printf("error: "); break;
case ALPM_LOG_WARNING: printf("warning: "); break;
default: return; /* skip other messages */
}
- vprintf(event->fmt, event->args);
+ vprintf(fmt, args);
}
int main(int argc, char *argv[])
@@ -61,7 +59,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);
/* set gpgdir to default */
alpm_option_set_gpgdir(handle, GPGDIR);