summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-01-19 02:42:21 +0100
committerAllan McRae <allan@archlinux.org>2013-01-28 14:38:46 +0100
commit66a9b5314123b3632cb90a4d37fd422a0f898568 (patch)
tree689776d6536072ed623813fae6e088969d01498f /lib/libalpm/util.c
parent8308c7b320ae230252ff0e79ea18cbfed0d13e81 (diff)
downloadpacman-66a9b5314123b3632cb90a4d37fd422a0f898568.tar.gz
pacman-66a9b5314123b3632cb90a4d37fd422a0f898568.tar.xz
add caller prefix to alpm_logaction
prefix defaults to "UNKOWN" if null or an empty string is provided. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r--lib/libalpm/util.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 7d9ee635..5960be6a 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -453,10 +453,15 @@ ssize_t _alpm_files_in_directory(alpm_handle_t *handle, const char *path,
* @return 0 or number of characters written on success, vfprintf return value
* on error
*/
-int _alpm_logaction(alpm_handle_t *handle, const char *fmt, va_list args)
+int _alpm_logaction(alpm_handle_t *handle, const char *prefix,
+ const char *fmt, va_list args)
{
int ret = 0;
+ if(!(prefix && *prefix)) {
+ prefix = "UNKNOWN";
+ }
+
if(handle->usesyslog) {
/* we can't use a va_list more than once, so we need to copy it
* so we can use the original when calling vfprintf below. */
@@ -474,9 +479,9 @@ int _alpm_logaction(alpm_handle_t *handle, const char *fmt, va_list args)
tm = localtime(&t);
/* Use ISO-8601 date format */
- fprintf(handle->logstream, "[%04d-%02d-%02d %02d:%02d] ",
+ fprintf(handle->logstream, "[%04d-%02d-%02d %02d:%02d] [%s] ",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min);
+ tm->tm_hour, tm->tm_min, prefix);
ret = vfprintf(handle->logstream, fmt, args);
fflush(handle->logstream);
}
@@ -568,7 +573,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[])
char line[PATH_MAX];
if(fgets(line, PATH_MAX, pipe_file) == NULL)
break;
- alpm_logaction(handle, "%s", line);
+ alpm_logaction(handle, "ALPM-SCRIPTLET", "%s", line);
EVENT(handle, ALPM_EVENT_SCRIPTLET_INFO, line, NULL);
}
fclose(pipe_file);