diff options
Diffstat (limited to 'upstream/mageia-cauldron/man3/sd_journal_stream_fd.3')
-rw-r--r-- | upstream/mageia-cauldron/man3/sd_journal_stream_fd.3 | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/upstream/mageia-cauldron/man3/sd_journal_stream_fd.3 b/upstream/mageia-cauldron/man3/sd_journal_stream_fd.3 new file mode 100644 index 00000000..f505e221 --- /dev/null +++ b/upstream/mageia-cauldron/man3/sd_journal_stream_fd.3 @@ -0,0 +1,133 @@ +'\" t +.TH "SD_JOURNAL_STREAM_FD" "3" "" "systemd 255" "sd_journal_stream_fd" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +sd_journal_stream_fd \- Create log stream file descriptor to the journal +.SH "SYNOPSIS" +.sp +.ft B +.nf +#include <systemd/sd\-journal\&.h> +.fi +.ft +.HP \w'int\ sd_journal_stream_fd('u +.BI "int sd_journal_stream_fd(const\ char\ *" "identifier" ", int\ " "priority" ", int\ " "level_prefix" ");" +.SH "DESCRIPTION" +.PP +\fBsd_journal_stream_fd()\fR +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\&. +.PP +\fBsd_journal_stream_fd()\fR +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 +\fBsystemd.journal-fields\fR(7) +for more information)\&. The second argument shall be the default priority level for all messages\&. The priority level is one of +\fBLOG_EMERG\fR, +\fBLOG_ALERT\fR, +\fBLOG_CRIT\fR, +\fBLOG_ERR\fR, +\fBLOG_WARNING\fR, +\fBLOG_NOTICE\fR, +\fBLOG_INFO\fR, +\fBLOG_DEBUG\fR, as defined in +syslog\&.h, see +\fBsyslog\fR(3) +for details\&. The third argument is a boolean: if true kernel\-style log level prefixes (such as +\fBSD_WARNING\fR) are interpreted, see +\fBsd-daemon\fR(3) +for more information\&. +.PP +It is recommended that applications log UTF\-8 messages only with this API, but this is not enforced\&. +.PP +Each invocation of +\fBsd_journal_stream_fd()\fR +allocates a new log stream file descriptor, that is not shared with prior or later invocations\&. The file descriptor is write\-only (its reading direction is shut down), and +\fBO_NONBLOCK\fR +is turned off initially\&. +.SH "RETURN VALUE" +.PP +The call returns a valid write\-only file descriptor on success or a negative errno\-style error code\&. +.SH "SIGNAL SAFETY" +.PP +\fBsd_journal_stream_fd()\fR +is "async signal safe" in the meaning of +\fBsignal-safety\fR(7)\&. +.SH "NOTES" +.PP +All functions listed here are thread\-safe and may be called in parallel from multiple threads\&. +.PP +Functions described here are available as a shared library, which can be compiled against and linked to with the +\fBlibsystemd\fR\ \&\fBpkg-config\fR(1) +file\&. +.SH "EXAMPLES" +.PP +Creating a log stream suitable for +\fBfprintf\fR(3): +.sp +.if n \{\ +.RS 4 +.\} +.nf +/* SPDX\-License\-Identifier: MIT\-0 */ + +#include <errno\&.h> +#include <syslog\&.h> +#include <stdio\&.h> +#include <unistd\&.h> +#include <systemd/sd\-journal\&.h> +#include <systemd/sd\-daemon\&.h> + +int main(int argc, char *argv[]) { + int fd; + FILE *log; + fd = sd_journal_stream_fd("test", LOG_INFO, 1); + if (fd < 0) { + errno = \-fd; + fprintf(stderr, "Failed to create stream fd: %m\en"); + return 1; + } + log = fdopen(fd, "w"); + if (!log) { + fprintf(stderr, "Failed to create file object: %m\en"); + close(fd); + return 1; + } + fprintf(log, "Hello World!\en"); + fprintf(log, SD_WARNING "This is a warning!\en"); + fclose(log); + return 0; +} +.fi +.if n \{\ +.RE +.\} +.SH "HISTORY" +.PP +\fBsd_journal_stream_fd()\fR +was added in version 187\&. +.SH "SEE ALSO" +.PP +\fBsystemd\fR(1), +\fBsd-journal\fR(3), +\fBsd-daemon\fR(3), +\fBsd_journal_print\fR(3), +\fBsyslog\fR(3), +\fBfprintf\fR(3), +\fBsystemd.journal-fields\fR(7) |