summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-06-07 20:55:13 -0400
committerDan McGee <dan@archlinux.org>2007-06-09 12:57:50 -0400
commita32ca90192ea2b2df2fadb820c9e47bbaec93151 (patch)
tree7f105ea98d8fbc52ed978c7efe4a4204e33a22f2 /src
parentfc93601b9887ec42cd71339099eadc6fb7b775e5 (diff)
Remove logmask stuff from backend; switch logging callback to new pm_printf
Remove the logmask functionality from the backend as it has been moved to the frontend, and change the logging callback function to use pm_printf. In addition, make much better use of va_list- use the args list instead of a arbitrarily chosen string to print to in the logging functions. Signed-off-by: Dan McGee <dan@archlinux.org>
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);
}
}