diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 10:52:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 10:52:03 +0000 |
commit | 932e4432596447eb9331cc2a2bb74a26a35b4efc (patch) | |
tree | 95161711ea07fd64f0c82d6e7943024c033dd5a8 /upstream/debian-unstable/man5/org.freedesktop.LogControl1.5 | |
parent | Adding debian version 4.22.0-1. (diff) | |
download | manpages-l10n-932e4432596447eb9331cc2a2bb74a26a35b4efc.tar.xz manpages-l10n-932e4432596447eb9331cc2a2bb74a26a35b4efc.zip |
Merging upstream version 4.23.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'upstream/debian-unstable/man5/org.freedesktop.LogControl1.5')
-rw-r--r-- | upstream/debian-unstable/man5/org.freedesktop.LogControl1.5 | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/upstream/debian-unstable/man5/org.freedesktop.LogControl1.5 b/upstream/debian-unstable/man5/org.freedesktop.LogControl1.5 index 70733a8e..30ea304e 100644 --- a/upstream/debian-unstable/man5/org.freedesktop.LogControl1.5 +++ b/upstream/debian-unstable/man5/org.freedesktop.LogControl1.5 @@ -1,5 +1,5 @@ '\" t -.TH "ORG\&.FREEDESKTOP\&.LOGCONTROL1" "5" "" "systemd 255" "org.freedesktop.LogControl1" +.TH "ORG\&.FREEDESKTOP\&.LOGCONTROL1" "5" "" "systemd 256~rc3" "org.freedesktop.LogControl1" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -181,13 +181,10 @@ for details about #define _cleanup_(f) __attribute__((cleanup(f))) -#define check(log_level, x) ({ \e - int _r = (x); \e - errno = _r < 0 ? \-_r : 0; \e - sd_journal_print((log_level), #x ": %m"); \e - if (_r < 0) \e - return EXIT_FAILURE; \e - }) +static int log_error(int log_level, int error, const char *str) { + sd_journal_print(log_level, "%s failed: %s", str, strerror(\-error)); + return error; +} typedef enum LogTarget { LOG_TARGET_JOURNAL, @@ -265,7 +262,8 @@ static int property_set( return r; if (strcmp(property, "LogLevel") == 0) { - for (int i = 0; i < LOG_DEBUG + 1; i++) + int i; + for (i = 0; i < LOG_DEBUG + 1; i++) if (strcmp(value, log_level_table[i]) == 0) { o\->log_level = i; setlogmask(LOG_UPTO(i)); @@ -279,7 +277,8 @@ static int property_set( } if (strcmp(property, "LogTarget") == 0) { - for (LogTarget i = 0; i < _LOG_TARGET_MAX; i++) + LogTarget i; + for (i = 0; i < _LOG_TARGET_MAX; i++) if (strcmp(value, log_target_table[i]) == 0) { o\->log_target = i; return 0; @@ -331,6 +330,7 @@ int main(int argc, char **argv) { \&.log_target = LOG_TARGET_JOURNAL, \&.syslog_identifier = "example", }; + int r; /* https://man7\&.org/linux/man\-pages/man3/setlogmask\&.3\&.html * Programs using syslog() instead of sd_journal can use this API to cut logs @@ -341,37 +341,49 @@ int main(int argc, char **argv) { /* Acquire a connection to the bus, letting the library work out the details\&. * https://www\&.freedesktop\&.org/software/systemd/man/sd_bus_default\&.html */ - check(o\&.log_level, sd_bus_default(&bus)); + r = sd_bus_default(&bus); + if (r < 0) + return log_error(o\&.log_level, r, "sd_bus_default()"); /* Publish an interface on the bus, specifying our well\-known object access * path and public interface name\&. * https://www\&.freedesktop\&.org/software/systemd/man/sd_bus_add_object\&.html * https://dbus\&.freedesktop\&.org/doc/dbus\-tutorial\&.html */ - check(o\&.log_level, sd_bus_add_object_vtable(bus, NULL, - "/org/freedesktop/LogControl1", - "org\&.freedesktop\&.LogControl1", - vtable, - &o)); + r = sd_bus_add_object_vtable(bus, NULL, + "/org/freedesktop/LogControl1", + "org\&.freedesktop\&.LogControl1", + vtable, + &o); + if (r < 0) + return log_error(o\&.log_level, r, "sd_bus_add_object_vtable()"); /* By default the service is assigned an ephemeral name\&. Also add a fixed * one, so that clients know whom to call\&. * https://www\&.freedesktop\&.org/software/systemd/man/sd_bus_request_name\&.html */ - check(o\&.log_level, sd_bus_request_name(bus, "org\&.freedesktop\&.Example", 0)); + r = sd_bus_request_name(bus, "org\&.freedesktop\&.Example", 0); + if (r < 0) + return log_error(o\&.log_level, r, "sd_bus_request_name()"); for (;;) { /* https://www\&.freedesktop\&.org/software/systemd/man/sd_bus_wait\&.html */ - check(o\&.log_level, sd_bus_wait(bus, UINT64_MAX)); + r = sd_bus_wait(bus, UINT64_MAX); + if (r < 0) + return log_error(o\&.log_level, r, "sd_bus_wait()"); /* https://www\&.freedesktop\&.org/software/systemd/man/sd_bus_process\&.html */ - check(o\&.log_level, sd_bus_process(bus, NULL)); + r = sd_bus_process(bus, NULL); + if (r < 0) + return log_error(o\&.log_level, r, "sd_bus_process()"); } /* https://www\&.freedesktop\&.org/software/systemd/man/sd_bus_release_name\&.html */ - check(o\&.log_level, sd_bus_release_name(bus, "org\&.freedesktop\&.Example")); + r = sd_bus_release_name(bus, "org\&.freedesktop\&.Example"); + if (r < 0) + return log_error(o\&.log_level, r, "sd_bus_release_name()"); return 0; } @@ -384,8 +396,4 @@ This creates a simple server on the bus\&. It implements the LogControl1 interfa \fBsd_journal_print\fR(3)\&. .SH "SEE ALSO" .PP -\fBsystemd\fR(1), -\fBjournalctl\fR(1), -\fBsystemctl\fR(1), -\fBsystemd.service\fR(5), -\fBsyslog\fR(3) +\fBsystemd\fR(1), \fBjournalctl\fR(1), \fBsystemctl\fR(1), \fBsystemd.service\fR(5), \fBsyslog\fR(3) |