From 66a9b5314123b3632cb90a4d37fd422a0f898568 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Fri, 18 Jan 2013 20:42:21 -0500 Subject: add caller prefix to alpm_logaction prefix defaults to "UNKOWN" if null or an empty string is provided. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/callback.c | 24 ++++++++++++++---------- src/pacman/pacman.c | 3 ++- src/pacman/pacman.h | 2 ++ src/pacman/sync.c | 6 ++++-- 4 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/pacman/callback.c b/src/pacman/callback.c index f53f59c8..93418db3 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -31,6 +31,7 @@ #include /* pacman */ +#include "pacman.h" #include "callback.h" #include "util.h" #include "conf.h" @@ -176,9 +177,10 @@ void cb_event(alpm_event_t event, void *data1, void *data2) } break; case ALPM_EVENT_ADD_DONE: - alpm_logaction(config->handle, "installed %s (%s)\n", - alpm_pkg_get_name(data1), - alpm_pkg_get_version(data1)); + alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, + "installed %s (%s)\n", + alpm_pkg_get_name(data1), + alpm_pkg_get_version(data1)); display_optdepends(data1); break; case ALPM_EVENT_REMOVE_START: @@ -187,9 +189,10 @@ void cb_event(alpm_event_t event, void *data1, void *data2) } break; case ALPM_EVENT_REMOVE_DONE: - alpm_logaction(config->handle, "removed %s (%s)\n", - alpm_pkg_get_name(data1), - alpm_pkg_get_version(data1)); + alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, + "removed %s (%s)\n", + alpm_pkg_get_name(data1), + alpm_pkg_get_version(data1)); break; case ALPM_EVENT_UPGRADE_START: if(config->noprogressbar) { @@ -197,10 +200,11 @@ void cb_event(alpm_event_t event, void *data1, void *data2) } break; case ALPM_EVENT_UPGRADE_DONE: - alpm_logaction(config->handle, "upgraded %s (%s -> %s)\n", - alpm_pkg_get_name(data1), - alpm_pkg_get_version(data2), - alpm_pkg_get_version(data1)); + alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, + "upgraded %s (%s -> %s)\n", + alpm_pkg_get_name(data1), + alpm_pkg_get_version(data2), + alpm_pkg_get_version(data1)); display_new_optdepends(data2, data1); break; case ALPM_EVENT_INTEGRITY_START: diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index f3ca8b97..8448d6b4 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -744,7 +744,8 @@ static void cl_to_log(int argc, char *argv[]) *p++ = ' '; } strcpy(p, argv[i]); - alpm_logaction(config->handle, "Running '%s'\n", cl_text); + alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, + "Running '%s'\n", cl_text); free(cl_text); } diff --git a/src/pacman/pacman.h b/src/pacman/pacman.h index 4eaf3182..7c9c365c 100644 --- a/src/pacman/pacman.h +++ b/src/pacman/pacman.h @@ -22,6 +22,8 @@ #include +#define PACMAN_CALLER_PREFIX "PACMAN" + /* database.c */ int pacman_database(alpm_list_t *targets); /* deptest.c */ diff --git a/src/pacman/sync.c b/src/pacman/sync.c index fef2940a..3decc40d 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -787,7 +787,8 @@ static int sync_trans(alpm_list_t *targets) if(config->op_s_upgrade) { printf(_(":: Starting full system upgrade...\n")); - alpm_logaction(config->handle, "starting full system upgrade\n"); + alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, + "starting full system upgrade\n"); if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) { pm_printf(ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle))); trans_release(); @@ -954,7 +955,8 @@ int pacman_sync(alpm_list_t *targets) if(config->op_s_sync) { /* grab a fresh package list */ printf(_(":: Synchronizing package databases...\n")); - alpm_logaction(config->handle, "synchronizing package lists\n"); + alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, + "synchronizing package lists\n"); if(!sync_synctree(config->op_s_sync, sync_dbs)) { return 1; } -- cgit v1.2.3-70-g09d2