summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-16 22:05:56 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-16 22:05:56 +0200
commit7866e76865a125c6b714e7c5833cd4e0aafe27e1 (patch)
tree6936fd656330529a4237a08e5505dbb586bae832
parent4f727471762d47a0d5690c18a98bb3682ea901b0 (diff)
Convert systemd to use debugging
-rw-r--r--main.h1
-rw-r--r--systemd.c26
2 files changed, 14 insertions, 13 deletions
diff --git a/main.h b/main.h
index 132e81a..dd93474 100644
--- a/main.h
+++ b/main.h
@@ -27,6 +27,7 @@ enum debug_category {
DBG_RCON = (0x1 << 11),
DBG_IDLE = (0x1 << 12),
DBG_IGMP = (0x1 << 13),
+ DBG_SYSD = (0x1 << 14),
};
static inline bool
diff --git a/systemd.c b/systemd.c
index a4dc53f..21268b7 100644
--- a/systemd.c
+++ b/systemd.c
@@ -37,7 +37,7 @@ systemd_service_object_path(struct cfg *cfg, const char *service)
const char *s;
if (empty_str(service)) {
- fprintf(stderr, "%s: called with NULL arg\n", __func__);
+ error("invalid arguments\n");
return NULL;
}
@@ -86,7 +86,7 @@ get_bus(struct cfg *cfg)
if (!cfg->sd_bus) {
r = sd_bus_open_user(&cfg->sd_bus);
if (r < 0) {
- fprintf(stderr, "Failed to connect to user system bus: %s\n", strerror(-r));
+ error("failed to connect to user system bus: %s\n", strerror(-r));
cfg->sd_bus_failed = true;
return NULL;
}
@@ -126,18 +126,18 @@ systemd_service_running(struct cfg *cfg, struct server *server)
&error,
&status);
if (r < 0) {
- fprintf(stderr, "%s: failed to get status for service %s (%s): %s\n",
- __func__, server->systemd_service, server->systemd_obj, error.message);
+ error("failed to get status for service %s (%s): %s\n",
+ server->systemd_service, server->systemd_obj, error.message);
goto out;
}
if (!strcmp(status, "active")) {
running = true;
- fprintf(stderr, "Systemd service %s (%s) is active\n",
- server->systemd_service, server->systemd_obj);
+ debug(DBG_SYSD, "systemd service %s (%s) is active\n",
+ server->systemd_service, server->systemd_obj);
} else
- fprintf(stderr, "Systemd service %s (%s) is not active\n",
- server->systemd_service, server->systemd_obj);
+ debug(DBG_SYSD, "systemd service %s (%s) is not active\n",
+ server->systemd_service, server->systemd_obj);
out:
xfree(status);
@@ -168,19 +168,19 @@ systemd_service_action(struct cfg *cfg, struct server *server, const char *actio
"s",
"fail");
if (r < 0) {
- fprintf(stderr, "Failed to perform action %s on systemd service %s: %s\n",
- action, server->systemd_service, error.message);
+ error("failed to perform action %s on systemd service %s: %s\n",
+ action, server->systemd_service, error.message);
goto out;
}
r = sd_bus_message_read(m, "o", &path);
if (r < 0) {
- fprintf(stderr, "Failed to parse response message: %s\n", strerror(-r));
+ error("failed to parse response message: %s\n", strerror(-r));
goto out;
}
- fprintf(stderr, "Queued %s on service %s as %s\n",
- action, server->systemd_service, path);
+ verbose("action %s queued for service %s\n",
+ action, server->systemd_service);
performed = true;
out: