1:255.13-alt1
[systemd_ALT.git] / man / journal-stream-fd.c
blob8aad5ff8c66e0c3a733acdcf37f40797e22ba64b
1 /* SPDX-License-Identifier: MIT-0 */
3 #include <errno.h>
4 #include <syslog.h>
5 #include <stdio.h>
6 #include <unistd.h>
7 #include <systemd/sd-journal.h>
8 #include <systemd/sd-daemon.h>
10 int main(int argc, char *argv[]) {
11 int fd;
12 FILE *log;
13 fd = sd_journal_stream_fd("test", LOG_INFO, 1);
14 if (fd < 0) {
15 errno = -fd;
16 fprintf(stderr, "Failed to create stream fd: %m\n");
17 return 1;
19 log = fdopen(fd, "w");
20 if (!log) {
21 fprintf(stderr, "Failed to create file object: %m\n");
22 close(fd);
23 return 1;
25 fprintf(log, "Hello World!\n");
26 fprintf(log, SD_WARNING "This is a warning!\n");
27 fclose(log);
28 return 0;