]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/journal-stream-fd.c
update TODO
[thirdparty/systemd.git] / man / journal-stream-fd.c
CommitLineData
1fe6d37e 1/* SPDX-License-Identifier: MIT-0 */
29c45dc4 2
b4096cec 3#include <errno.h>
29c45dc4
ZJS
4#include <syslog.h>
5#include <stdio.h>
29c45dc4
ZJS
6#include <unistd.h>
7#include <systemd/sd-journal.h>
8#include <systemd/sd-daemon.h>
9
10int 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) {
b4096cec
ZJS
15 errno = -fd;
16 fprintf(stderr, "Failed to create stream fd: %m\n");
29c45dc4
ZJS
17 return 1;
18 }
19 log = fdopen(fd, "w");
20 if (!log) {
21 fprintf(stderr, "Failed to create file object: %m\n");
22 close(fd);
23 return 1;
24 }
25 fprintf(log, "Hello World!\n");
26 fprintf(log, SD_WARNING "This is a warning!\n");
27 fclose(log);
28 return 0;
29}