summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/log.c')
-rw-r--r--lib/libalpm/log.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 09c6fb84..91bcb823 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -22,10 +22,7 @@
#include <stdio.h>
#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <errno.h>
-#include <time.h>
/* libalpm */
#include "log.h"
@@ -39,18 +36,16 @@
*/
/** A printf-like function for logging.
+ * @param handle the context handle
* @param fmt output format
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int SYMEXPORT alpm_logaction(const char *fmt, ...)
+int SYMEXPORT alpm_logaction(pmhandle_t *handle, const char *fmt, ...)
{
int ret;
va_list args;
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
/* check if the logstream is open already, opening it if needed */
if(handle->logstream == NULL) {
@@ -58,18 +53,18 @@ int SYMEXPORT alpm_logaction(const char *fmt, ...)
/* if we couldn't open it, we have an issue */
if(handle->logstream == NULL) {
if(errno == EACCES) {
- pm_errno = PM_ERR_BADPERMS;
+ handle->pm_errno = PM_ERR_BADPERMS;
} else if(errno == ENOENT) {
- pm_errno = PM_ERR_NOT_A_DIR;
+ handle->pm_errno = PM_ERR_NOT_A_DIR;
} else {
- pm_errno = PM_ERR_SYSTEM;
+ handle->pm_errno = PM_ERR_SYSTEM;
}
- return(-1);
+ return -1;
}
}
va_start(args, fmt);
- ret = _alpm_logaction(handle->usesyslog, handle->logstream, fmt, args);
+ ret = _alpm_logaction(handle, fmt, args);
va_end(args);
/* TODO We should add a prefix to log strings depending on who called us.
@@ -83,15 +78,15 @@ int SYMEXPORT alpm_logaction(const char *fmt, ...)
* kpacman: "KPACMAN"
* This would allow us to share the log file between several frontends
* and know who does what */
- return(ret);
+ return ret;
}
/** @} */
-void _alpm_log(pmloglevel_t flag, const char *fmt, ...)
+void _alpm_log(pmhandle_t *handle, pmloglevel_t flag, const char *fmt, ...)
{
va_list args;
- alpm_cb_log logcb = alpm_option_get_logcb();
+ alpm_cb_log logcb = alpm_option_get_logcb(handle);
if(logcb == NULL) {
return;