2
.\" Title: sd_journal_stream_fd
3
.\" Author: Lennart Poettering <lennart@poettering.net>
4
.\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
6
.\" Manual: sd_journal_stream_fd
10
.TH "SD_JOURNAL_STREAM_FD" "3" "" "systemd" "sd_journal_stream_fd"
11
.\" -----------------------------------------------------------------
12
.\" * Define some portability stuff
13
.\" -----------------------------------------------------------------
14
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
.\" http://bugs.debian.org/507673
16
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
.\" -----------------------------------------------------------------
21
.\" * set default formatting
22
.\" -----------------------------------------------------------------
23
.\" disable hyphenation
25
.\" disable justification (adjust text to left margin only)
27
.\" -----------------------------------------------------------------
28
.\" * MAIN CONTENT STARTS HERE *
29
.\" -----------------------------------------------------------------
31
sd_journal_stream_fd \- Create log stream file descriptor to the journal
36
#include <systemd/sd\-journal\&.h>
39
.HP \w'int\ sd_journal_stream_fd('u
40
.BI "int sd_journal_stream_fd(const\ char*\ " "identifier" ", int\ " "priority" ", int\ " "level_prefix" ");"
43
\fBsd_journal_stream_fd()\fR
44
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 STDOUT/STDERR of other processes executed\&.
46
\fBsd_journal_stream_fd()\fR
47
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
48
\fBsystemd.journal-fields\fR(7)
49
for more information)\&. The second argument shall be the default priority level for all messages\&. The priority level is one of
57
LOG_DEBUG, as defined in
60
for details\&. The third argument is a boolean: if true kernel\-style log priority level prefixes (such as
61
SD_WARNING) are interpreted, see
63
for more information\&.
65
It is recommended that applications log UTF\-8 messages only with this API, but this is not enforced\&.
68
The call returns a valid write\-only file descriptor on success or a negative errno\-style error code\&.
72
\fBsd_journal_stream_fd()\fR
73
interface is available as shared library, which can be compiled and linked to with the
79
Creating a log stream suitable for
90
#include <systemd/sd\-journal\&.h>
91
#include <systemd/sd\-daemon\&.h>
93
int main(int argc, char *argv[]) {
96
fd = sd_journal_stream_fd("test", LOG_INFO, 1);
98
fprintf(stderr, "Failed to create stream fd: %s\en", strerror(\-fd));
101
log = fdopen(fd, "w");
103
fprintf(stderr, "Failed to create file object: %m\en");
107
fprintf(log, "Hello World!\en");
108
fprintf(log, SD_WARNING "This is a warning!\en");
122
\fBsd_journal_print\fR(3),
125
\fBsystemd.journal-fields\fR(7)