Enable syslog logging by default; updated API to use xbps_handle::flags.
This commit is contained in:
parent
dfab6cc441
commit
6bb61adb0e
2
NEWS
2
NEWS
@ -1,5 +1,7 @@
|
||||
xbps-0.37 (???):
|
||||
|
||||
* Enabled syslog logging by default, may be still disabled via xbps.conf.
|
||||
|
||||
* Added support for system and configuration virtualpkg directories.
|
||||
|
||||
The system virtualpkg directory set to <rootdir>/usr/share/xbps/virtualpkg.d contains
|
||||
|
@ -38,8 +38,10 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
const char *instver, *newver;
|
||||
char *pkgname;
|
||||
int rv = 0;
|
||||
bool slog = false;
|
||||
|
||||
if (xscd->xhp->syslog) {
|
||||
if ((xscd->xhp->flags & XBPS_FLAG_DISABLE_SYSLOG) == 0) {
|
||||
slog = true;
|
||||
openlog("xbps-install", LOG_CONS, LOG_USER);
|
||||
}
|
||||
|
||||
@ -103,7 +105,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
break;
|
||||
case XBPS_STATE_INSTALL_DONE:
|
||||
printf("%s: installed successfully.\n", xscd->arg);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_NOTICE, "Installed `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
@ -111,7 +113,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
break;
|
||||
case XBPS_STATE_UPDATE_DONE:
|
||||
printf("%s: updated successfully.\n", xscd->arg);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_NOTICE, "Updated `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
@ -119,7 +121,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
break;
|
||||
case XBPS_STATE_REMOVE_DONE:
|
||||
printf("%s: removed successfully.\n", xscd->arg);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_NOTICE, "Removed `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
@ -140,7 +142,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
case XBPS_STATE_REPOSYNC_FAIL:
|
||||
case XBPS_STATE_CONFIG_FILE_FAIL:
|
||||
xbps_error_printf("%s\n", xscd->desc);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
}
|
||||
break;
|
||||
@ -152,7 +154,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
return 0;
|
||||
|
||||
xbps_error_printf("%s\n", xscd->desc);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
}
|
||||
break;
|
||||
|
@ -53,7 +53,10 @@ usage(bool fail)
|
||||
static int
|
||||
state_cb(struct xbps_state_cb_data *xscd, void *cbd _unused)
|
||||
{
|
||||
if (xscd->xhp->syslog) {
|
||||
bool slog = false;
|
||||
|
||||
if ((xscd->xhp->flags & XBPS_FLAG_DISABLE_SYSLOG) == 0) {
|
||||
slog = true;
|
||||
openlog("xbps-reconfigure", LOG_CONS, LOG_USER);
|
||||
}
|
||||
|
||||
@ -61,19 +64,19 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbd _unused)
|
||||
/* notifications */
|
||||
case XBPS_STATE_CONFIGURE:
|
||||
printf("%s: configuring ...\n", xscd->arg);
|
||||
if (xscd->xhp->syslog)
|
||||
if (slog)
|
||||
syslog(LOG_NOTICE, "%s: configuring ...", xscd->arg);
|
||||
break;
|
||||
case XBPS_STATE_CONFIGURE_DONE:
|
||||
printf("%s: configured successfully.\n", xscd->arg);
|
||||
if (xscd->xhp->syslog)
|
||||
if (slog)
|
||||
syslog(LOG_NOTICE,
|
||||
"%s: configured successfully.", xscd->arg);
|
||||
break;
|
||||
/* errors */
|
||||
case XBPS_STATE_CONFIGURE_FAIL:
|
||||
xbps_error_printf("%s\n", xscd->desc);
|
||||
if (xscd->xhp->syslog)
|
||||
if (slog)
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
break;
|
||||
default:
|
||||
|
@ -65,7 +65,10 @@ usage(bool fail)
|
||||
static int
|
||||
state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
{
|
||||
if (xscd->xhp->syslog) {
|
||||
bool slog = false;
|
||||
|
||||
if ((xscd->xhp->flags & XBPS_FLAG_DISABLE_SYSLOG) == 0) {
|
||||
slog = true;
|
||||
openlog("xbps-remove", LOG_CONS, LOG_USER);
|
||||
}
|
||||
|
||||
@ -82,7 +85,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
break;
|
||||
case XBPS_STATE_REMOVE_DONE:
|
||||
printf("Removed `%s' successfully.\n", xscd->arg);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_NOTICE, "Removed `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
@ -91,7 +94,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
/* errors */
|
||||
case XBPS_STATE_REMOVE_FAIL:
|
||||
xbps_error_printf("%s\n", xscd->desc);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
}
|
||||
break;
|
||||
@ -103,7 +106,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata _unused)
|
||||
return 0;
|
||||
|
||||
xbps_error_printf("%s\n", xscd->desc);
|
||||
if (xscd->xhp->syslog) {
|
||||
if (slog) {
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
}
|
||||
break;
|
||||
|
@ -10,8 +10,8 @@
|
||||
# otherwise it's relative to rootdir.
|
||||
#cachedir=var/cache/xbps
|
||||
|
||||
# comment it out to disable syslog logging.
|
||||
syslog=true
|
||||
# Set it to false to disable syslog logging.
|
||||
#syslog=true
|
||||
|
||||
## REPOSITORIES
|
||||
#
|
||||
|
@ -48,7 +48,7 @@
|
||||
*
|
||||
* This header documents the full API for the XBPS Library.
|
||||
*/
|
||||
#define XBPS_API_VERSION "20140531"
|
||||
#define XBPS_API_VERSION "20140604"
|
||||
|
||||
#ifndef XBPS_VERSION
|
||||
#define XBPS_VERSION "UNSET"
|
||||
@ -198,6 +198,13 @@
|
||||
*/
|
||||
#define XBPS_FLAG_FORCE_UNPACK 0x00000040
|
||||
|
||||
/**
|
||||
* @def XBPS_FLAG_DISABLE_SYSLOG
|
||||
* Disable syslog logging, enabled by default.
|
||||
* Must be set through the xbps_handle::flags member.
|
||||
*/
|
||||
#define XBPS_FLAG_DISABLE_SYSLOG 0x00000080
|
||||
|
||||
/**
|
||||
* @def XBPS_FETCH_CACHECONN
|
||||
* Default (global) limit of cached connections used in libfetch.
|
||||
@ -594,14 +601,9 @@ struct xbps_handle {
|
||||
* - XBPS_FLAG_FORCE_REMOVE_FILES
|
||||
* - XBPS_FLAG_DEBUG
|
||||
* - XBPS_FLAG_INSTALL_AUTO
|
||||
* - XBPS_FLAG_DISABLE_SYSLOG
|
||||
*/
|
||||
int flags;
|
||||
/**
|
||||
* @var syslog
|
||||
*
|
||||
* Set it to true to enable syslog logging.
|
||||
*/
|
||||
bool syslog;
|
||||
};
|
||||
|
||||
void xbps_dbg_printf(struct xbps_handle *, const char *, ...);
|
||||
|
@ -234,8 +234,11 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested, bool vpkgconf
|
||||
snprintf(xhp->cachedir, sizeof(xhp->cachedir), "%s", v);
|
||||
} else if (strcmp(k, "syslog") == 0) {
|
||||
if (strcasecmp(v, "true") == 0) {
|
||||
xhp->syslog = true;
|
||||
xhp->flags &= ~XBPS_FLAG_DISABLE_SYSLOG;
|
||||
xbps_dbg_printf(xhp, "%s: syslog enabled\n", path);
|
||||
} else {
|
||||
xhp->flags |= XBPS_FLAG_DISABLE_SYSLOG;
|
||||
xbps_dbg_printf(xhp, "%s: syslog disabled\n", path);
|
||||
}
|
||||
} else if (strcmp(k, "repository") == 0) {
|
||||
if (store_repo(xhp, v))
|
||||
@ -439,7 +442,7 @@ xbps_init(struct xbps_handle *xhp)
|
||||
xbps_dbg_printf(xhp, "rootdir=%s\n", xhp->rootdir);
|
||||
xbps_dbg_printf(xhp, "metadir=%s\n", xhp->metadir);
|
||||
xbps_dbg_printf(xhp, "cachedir=%s\n", xhp->cachedir);
|
||||
xbps_dbg_printf(xhp, "syslog=%s\n", xhp->syslog ? "true" : "false");
|
||||
xbps_dbg_printf(xhp, "syslog=%s\n", xhp->flags & XBPS_FLAG_DISABLE_SYSLOG ? "false" : "true");
|
||||
xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->native_arch);
|
||||
xbps_dbg_printf(xhp, "Target Architecture: %s\n", xhp->target_arch);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user