'\" t .TH "SD_JOURNAL_OPEN" "3" "" "systemd 204" "sd_journal_open" .\" ----------------------------------------------------------------- .\" * 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_open, sd_journal_open_directory, sd_journal_close, sd_journal, SD_JOURNAL_LOCAL_ONLY, SD_JOURNAL_RUNTIME_ONLY, SD_JOURNAL_SYSTEM_ONLY \- Open the system journal for reading .SH "SYNOPSIS" .sp .ft B .nf #include .fi .ft .HP \w'int\ sd_journal_open('u .BI "int sd_journal_open(sd_journal**\ " "ret" ", int\ " "flags" ");" .HP \w'int\ sd_journal_open_directory('u .BI "int sd_journal_open_directory(sd_journal**\ " "ret" ", const\ char*\ " "path" ", int\ " "flags" ");" .HP \w'void\ sd_journal_close('u .BI "void sd_journal_close(sd_journal*\ " "j" ");" .SH "DESCRIPTION" .PP \fBsd_journal_open()\fR opens the log journal for reading\&. It will find all journal files automatically and interleave them automatically when reading\&. As first argument it takes a pointer to a sd_journal pointer, which on success will contain journal context object afterwards\&. The second argument is a flags field, which may consist of the following flags ORed together: SD_JOURNAL_LOCAL_ONLY makes sure only journal files generated on the local machine will be opened\&. SD_JOURNAL_RUNTIME_ONLY makes sure only volatile journal files will be opened, excluding those which are stored on persistent storage\&. SD_JOURNAL_SYSTEM_ONLY will ensure that only journal files of system services and the kernel (in opposition to user session processes) will be opened\&. .PP \fBsd_journal_open_directory()\fR is similar to \fBsd_journal_open()\fR but takes an absolute directory path as argument\&. All journal files in this directory will be opened and interleaved automatically\&. This call also takes a flags argument, but it must be passed as 0 as no flags are currently understood for this call\&. .PP \fBsd_journal_close()\fR will close the journal context allocated with \fBsd_journal_open()\fR or \fBsd_journal_open_directory()\fR and free its resources\&. .PP When opening the journal only journal files accessible to the calling user will be opened\&. If journal files are not accessible to the caller this will be silently ignored\&. .PP See \fBsd_journal_next\fR(3) for an example how to iterate through the journal after opening it with \fBsd_journal_open()\fR\&. .PP A journal context object returned by \fBsd_journal_open()\fR references a specific journal entry as \fIcurrent\fR entry, similar to a file seek index in a classic file system file, but without absolute positions\&. It may be altered with \fBsd_journal_next\fR(3) and \fBsd_journal_seek_head\fR(3) and related calls\&. The current entry position may be exported in \fIcursor\fR strings, as accessible via \fBsd_journal_get_cursor\fR(3)\&. Cursor strings may be used to globally identify a specific journal entry in a stable way and then later to seek to it (or if the specific entry is not available locally, to its closest entry in time) \fBsd_journal_seek_cursor\fR(3)\&. .PP Notification of journal changes is available via \fBsd_journal_get_fd()\fR and related calls\&. .SH "RETURN VALUE" .PP The \fBsd_journal_open()\fR and \fBsd_journal_open_directory()\fR calls return 0 on success or a negative errno\-style error code\&. \fBsd_journal_close()\fR returns nothing\&. .SH "NOTES" .PP The \fBsd_journal_open()\fR, \fBsd_journal_open_directory()\fR and \fBsd_journal_close()\fR interfaces are available as shared library, which can be compiled and linked to with the libsystemd\-journal \fBpkg-config\fR(1) file\&. .SH "SEE ALSO" .PP \fBsystemd\fR(1), \fBsd-journal\fR(3), \fBsd_journal_next\fR(3), \fBsd_journal_get_data\fR(3)