Enable syslog logging by default; updated API to use xbps_handle::flags.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user