[pacman-dev] [PATCH 1/4] alpm_handle_t: add program name for use in log prefix
Andrew Gregory
andrew.gregory.8 at gmail.com
Thu Dec 20 17:09:47 EST 2012
Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---
lib/libalpm/alpm.c | 2 ++
lib/libalpm/alpm.h | 3 +++
lib/libalpm/handle.c | 18 ++++++++++++++++++
lib/libalpm/handle.h | 1 +
lib/libalpm/log.c | 11 -----------
5 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index c58a406..255e486 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -76,6 +76,8 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
bindtextdomain("libalpm", LOCALEDIR);
#endif
+ alpm_option_set_program(myhandle, "USER");
+
return myhandle;
cleanup:
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 5393b3b..3388735 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -563,6 +563,9 @@ const char *alpm_option_get_arch(alpm_handle_t *handle);
/** Sets the targeted architecture. */
int alpm_option_set_arch(alpm_handle_t *handle, const char *arch);
+const char *alpm_option_get_program(alpm_handle_t *handle);
+int alpm_option_set_program(alpm_handle_t *handle, const char *arch);
+
double alpm_option_get_deltaratio(alpm_handle_t *handle);
int alpm_option_set_deltaratio(alpm_handle_t *handle, double ratio);
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index d13be1c..45c6dab 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -79,6 +79,7 @@ void _alpm_handle_free(alpm_handle_t *handle)
FREE(handle->logfile);
FREE(handle->lockfile);
FREE(handle->arch);
+ FREE(handle->program);
FREE(handle->gpgdir);
FREELIST(handle->dbs_sync);
FREELIST(handle->noupgrade);
@@ -253,6 +254,12 @@ const char SYMEXPORT *alpm_option_get_arch(alpm_handle_t *handle)
return handle->arch;
}
+const char SYMEXPORT *alpm_option_get_program(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->program;
+}
+
double SYMEXPORT alpm_option_get_deltaratio(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
@@ -582,6 +589,17 @@ int SYMEXPORT alpm_option_set_arch(alpm_handle_t *handle, const char *arch)
}
return 0;
}
+int SYMEXPORT alpm_option_set_program(alpm_handle_t *handle, const char *program)
+{
+ CHECK_HANDLE(handle, return -1);
+ if(handle->program) FREE(handle->program);
+ if(program) {
+ handle->program = strdup(program);
+ } else {
+ handle->program = NULL;
+ }
+ return 0;
+}
int SYMEXPORT alpm_option_set_deltaratio(alpm_handle_t *handle, double ratio)
{
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 1b9c8c8..2a68b8e 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -96,6 +96,7 @@ struct __alpm_handle_t {
upgrade operations */
alpm_siglevel_t remotefilesiglevel; /* Signature verification level for remote file
upgrade operations */
+ char *program;
/* error code */
alpm_errno_t pm_errno;
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 8486716..5c4bf9a 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -65,17 +65,6 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *fmt, ...)
ret = _alpm_logaction(handle, fmt, args);
va_end(args);
- /* TODO We should add a prefix to log strings depending on who called us.
- * If logaction was called by the frontend:
- * USER: <the frontend log>
- * and if called internally:
- * ALPM: <the library log>
- * Moreover, the frontend should be able to choose its prefix
- * (USER by default?):
- * pacman: "PACMAN"
- * kpacman: "KPACMAN"
- * This would allow us to share the log file between several frontends
- * and know who does what */
return ret;
}
--
1.8.0.2
More information about the pacman-dev
mailing list