chiark / gitweb /
man: Split sd_randomize(3) from sd_id128_get_{machine,boot}(3)
[elogind.git] / man / sd_journal_open.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3         "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   This file is part of systemd.
7
8   Copyright 2012 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_journal_open">
25
26         <refentryinfo>
27                 <title>sd_journal_open</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Lennart</firstname>
34                                 <surname>Poettering</surname>
35                                 <email>lennart@poettering.net</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>sd_journal_open</refentrytitle>
42                 <manvolnum>3</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>sd_journal_open</refname>
47                 <refname>sd_journal_open_directory</refname>
48                 <refname>sd_journal_close</refname>
49                 <refpurpose>Open the system journal for reading</refpurpose>
50         </refnamediv>
51
52         <refsynopsisdiv>
53                 <funcsynopsis>
54                         <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
55
56                         <funcprototype>
57                                 <funcdef>int <function>sd_journal_open</function></funcdef>
58                                 <paramdef>sd_journal** <parameter>ret</parameter></paramdef>
59                                 <paramdef>int <parameter>flags</parameter></paramdef>
60                         </funcprototype>
61
62                         <funcprototype>
63                                 <funcdef>int <function>sd_journal_open_directory</function></funcdef>
64                                 <paramdef>sd_journal** <parameter>ret</parameter></paramdef>
65                                 <paramdef>const char* <parameter>path</parameter></paramdef>
66                                 <paramdef>int <parameter>flags</parameter></paramdef>
67                         </funcprototype>
68
69                         <funcprototype>
70                                 <funcdef>int <function>sd_journal_close</function></funcdef>
71                                 <paramdef>sd_journal* <parameter>j</parameter></paramdef>
72                         </funcprototype>
73                 </funcsynopsis>
74         </refsynopsisdiv>
75
76         <refsect1>
77                 <title>Description</title>
78
79                 <para><function>sd_journal_open()</function> opens the
80                 the log journal for reading. It will find all journal
81                 files automatically and interleave them automatically
82                 when reading. As first argument it takes a pointer to
83                 a <literal>sd_journal</literal> pointer, which on
84                 success will contain journal context afterwards. The
85                 second argument is a flags field, which may consist of
86                 the following flags ORed together:
87                 <literal>SD_JOURNAL_LOCAL_ONLY</literal> makes sure
88                 only journal files generated on the local machine will
89                 be opened. <literal>SD_JOURNAL_RUNTIME_ONLY</literal>
90                 makes sure only volatile journal files will be opened,
91                 excluding those which are stored on persistant
92                 storage. <literal>SD_JOURNAL_SYSTEM_ONLY</literal>
93                 will ensure that only journal files of system services
94                 and the kernel (in opposition to user session processes) will
95                 be opened.</para>
96
97                 <para><function>sd_journal_open_directory()</function>
98                 is similar to <function>sd_journal_open()</function>
99                 but takes an absolute directory path as argument. All
100                 journal files in this directory will be opened and
101                 interleaved automatically. This call also takes a
102                 flags argument, but it must be passed as 0 as no flags
103                 are currently understood for this call.</para>
104
105                 <para><function>sd_journal_close()</function> will
106                 close the journal context allocated with
107                 <function>sd_journal_open()</function> or
108                 <function>sd_journal_open_directory()</function> and
109                 free its resources.</para>
110
111                 <para>When opening the journal only journal files
112                 accessible to the calling user will be opened. If
113                 journal files are not accessible to the caller this
114                 will be silently ignored.</para>
115
116                 <para>See
117                 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
118                 for an example how to iterate through the journal
119                 after opening it it with
120                 <function>sd_journal_open()</function>.</para>
121
122                 <para>A journal context object returned by
123                 <function>sd_journal_open()</function> references a
124                 specific journal entry as <emphasis>current</emphasis> entry,
125                 similar to a file seek index in a classic file system
126                 file, but without absolute positions. It may be
127                 altered with
128                 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
129                 and
130                 <citerefentry><refentrytitle>sd_journal_seek_head</refentrytitle><manvolnum>3</manvolnum></citerefentry>
131                 and related calls. The current entry position may be
132                 exported in <emphasis>cursor</emphasis> strings, as accessible
133                 via
134                 <citerefentry><refentrytitle>sd_journal_get_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Cursor
135                 strings may be used to globally identify a specific
136                 journal entry in a stable way and then later to seek
137                 to it (or if the specific entry is not available
138                 locally, to its closest entry in time)
139                 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
140
141                 <para>Notification of journal changes is available via
142                 <function>sd_journal_get_fd()</function> and related
143                 calls.</para>
144         </refsect1>
145
146         <refsect1>
147                 <title>Return Value</title>
148
149                 <para>The <function>sd_journal_open()</function> and
150                 <function>sd_journal_open_directory()</function> calls
151                 return 0 on success or a negative errno-style error
152                 code. <function>sd_journal_close()</function> returns
153                 nothing.</para>
154         </refsect1>
155
156         <refsect1>
157                 <title>Notes</title>
158
159                 <para>The <function>sd_journal_open()</function>,
160                 <function>sd_journal_open_directory()</function> and
161                 <function>sd_journal_close()</function> interfaces are
162                 available as shared library, which can be compiled and
163                 linked to with the
164                 <literal>libsystemd-journal</literal>
165                 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
166                 file.</para>
167         </refsect1>
168
169         <refsect1>
170                 <title>See Also</title>
171
172                 <para>
173                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
174                         <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
175                         <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
176                         <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>
177                 </para>
178         </refsect1>
179
180 </refentry>