2 .TH "SD_JOURNAL_STREAM_FD" "3" "" "systemd 217" "sd_journal_stream_fd"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
17 .\" disable justification (adjust text to left margin only)
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
23 sd_journal_stream_fd \- Create log stream file descriptor to the journal
28 #include <systemd/sd\-journal\&.h>
31 .HP \w'int\ sd_journal_stream_fd('u
32 .BI "int sd_journal_stream_fd(const\ char\ *" "identifier" ", int\ " "priority" ", int\ " "level_prefix" ");"
35 \fBsd_journal_stream_fd()\fR
36 may be used to create a log stream file descriptor\&. Log messages written to this file descriptor as simple newline\-separated text strings are written to the journal\&. This file descriptor can be used internally by applications or be made standard output or standard error of other processes executed\&.
38 \fBsd_journal_stream_fd()\fR
39 takes a short program identifier string as first argument, which will be written to the journal as _SYSLOG_IDENTIFIER= field for each log entry (see
40 \fBsystemd.journal-fields\fR(7)
41 for more information)\&. The second argument shall be the default priority level for all messages\&. The priority level is one of
49 \fBLOG_DEBUG\fR, as defined in
52 for details\&. The third argument is a boolean: if true kernel\-style log priority level prefixes (such as
53 \fBSD_WARNING\fR) are interpreted, see
55 for more information\&.
57 It is recommended that applications log UTF\-8 messages only with this API, but this is not enforced\&.
60 The call returns a valid write\-only file descriptor on success or a negative errno\-style error code\&.
64 \fBsd_journal_stream_fd()\fR
65 interface is available as a shared library, which can be compiled and linked to with the
66 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
70 Creating a log stream suitable for
81 #include <systemd/sd\-journal\&.h>
82 #include <systemd/sd\-daemon\&.h>
84 int main(int argc, char *argv[]) {
87 fd = sd_journal_stream_fd("test", LOG_INFO, 1);
89 fprintf(stderr, "Failed to create stream fd: %s\en", strerror(\-fd));
92 log = fdopen(fd, "w");
94 fprintf(stderr, "Failed to create file object: %m\en");
98 fprintf(log, "Hello World!\en");
99 fprintf(log, SD_WARNING "This is a warning!\en");
112 \fBsd_journal_print\fR(3),
115 \fBsystemd.journal-fields\fR(7)