summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/callback.c47
-rw-r--r--src/pacman/callback.h2
-rw-r--r--src/util/testpkg.c7
3 files changed, 8 insertions, 48 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index baefacc0..607d6329 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -593,54 +593,13 @@ void cb_dl_progress(const char *filename, int xfered, int total)
}
/* Callback to handle notifications from the library */
-void cb_log(pmloglevel_t level, char *msg)
+void cb_log(pmloglevel_t level, char *fmt, va_list args)
{
- char str[LOG_STR_LEN] = "";
-
- if(!strlen(msg)) {
+ if(!strlen(fmt)) {
return;
}
- switch(level) {
- case PM_LOG_DEBUG:
- sprintf(str, _("debug"));
- break;
- case PM_LOG_ERROR:
- sprintf(str, _("error"));
- break;
- case PM_LOG_WARNING:
- sprintf(str, _("warning"));
- break;
- case PM_LOG_FUNCTION:
- /* TODO we should increase the indent level when this occurs so we can see
- * program flow easier. It'll be fun
- */
- sprintf(str, _("function"));
- break;
- default:
- sprintf(str, "???");
- break;
- }
-
-#ifdef PACMAN_DEBUG
- /* If debug is on, we'll timestamp the output */
- if(alpm_option_get_logmask() & PM_LOG_DEBUG) {
- time_t t;
- struct tm *tmp;
- char timestr[10] = {0};
-
- t = time(NULL);
- tmp = localtime(&t);
- strftime(timestr, 9, "%H:%M:%S", tmp);
- timestr[8] = '\0';
-
- printf("[%s] %s: %s\n", timestr, str, msg);
- } else {
- printf("%s: %s\n", str, msg);
- }
-#else
- printf("%s: %s\n", str, msg);
-#endif
+ pm_vfprintf(stdout, level, fmt, args);
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/callback.h b/src/pacman/callback.h
index 8494154a..742cd940 100644
--- a/src/pacman/callback.h
+++ b/src/pacman/callback.h
@@ -38,7 +38,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
void cb_dl_progress(const char *filename, int xfered, int total);
/* callback to handle messages/notifications from pacman library */
-void cb_log(pmloglevel_t level, char *msg);
+void cb_log(pmloglevel_t level, char *fmt, va_list args);
#endif /* _PM_CALLBACK_H */
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 66569f1e..1ad1d14b 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -23,20 +23,21 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <libgen.h>
#include <alpm.h>
-void output_cb(pmloglevel_t level, char *msg)
+void output_cb(pmloglevel_t level, char *fmt, va_list args)
{
- if(strlen(msg)) {
+ if(strlen(fmt)) {
switch(level) {
case PM_LOG_ERROR: printf("error: "); break;
case PM_LOG_WARNING: printf("warning: "); break;
default: break;
}
- puts(msg);
+ vprintf(fmt, args);
}
}