[pacman-dev] [PATCH 0/4] [RFC] add caller prefix to alpm_logaction

Andrew Gregory andrew.gregory.8 at gmail.com
Thu Dec 20 17:09:46 EST 2012


Implements the following TODO from alpm_logaction in log.c:

> 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     

The log prefix can be added two different ways.  To make it easier for
frontends, handle->program can be set to the program name (defaults to "USER")
which will be used for calls to alpm_logaction.  The prefix can be set per call
with alpm_plogaction; this is what alpm does.

Resulting logfile looks like this:

> [2012-12-20 16:29] [PACMAN] Running '/home/ag/devel/pacman/src/pacman/.libs/lt-pacman -Rdd pacman'
> [2012-12-20 16:29] [ALPM] warning: /etc/pacman.conf saved as /etc/pacman.conf.pacsave
> [2012-12-20 16:29] [PACMAN] removed pacman (4.0.3-5)
> [2012-12-20 16:29] [PACMAN] Running '/home/ag/devel/pacman/src/pacman/.libs/lt-pacman --conf /etc/pacman.conf.pacsave -S pacman'
> [2012-12-20 16:29] [ALPM-SCRIPTLET]  >>> Run  `pacman-key --init; pacman-key --populate archlinux`
> [2012-12-20 16:29] [ALPM-SCRIPTLET]  >>> to import the data required by pacman for package verification.
> [2012-12-20 16:29] [ALPM-SCRIPTLET]  >>> See: https://www.archlinux.org/news/having-pacman-verify-packages
> [2012-12-20 16:29] [PACMAN] installed pacman (4.0.3-5)

Andrew Gregory (4):
  alpm_handle_t: add program name for use in log prefix
  _alpm_logaction: add support for prefix
  log.c: add alpm_plogaction
  pacman: set program name for logging

 lib/libalpm/add.c    | 22 +++++++++++-----------
 lib/libalpm/alpm.c   |  2 ++
 lib/libalpm/alpm.h   |  4 ++++
 lib/libalpm/handle.c | 18 ++++++++++++++++++
 lib/libalpm/handle.h |  1 +
 lib/libalpm/log.c    | 50 ++++++++++++++++++++++++++++++++++++++------------
 lib/libalpm/remove.c |  6 +++---
 lib/libalpm/util.c   |  8 ++++++--
 lib/libalpm/util.h   |  2 +-
 src/pacman/conf.c    |  1 +
 10 files changed, 85 insertions(+), 29 deletions(-)

-- 
1.8.0.2



More information about the pacman-dev mailing list