chiark / gitweb /
man: improve readability of --output options in journalctl(1)
[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_open_files</refname>
49                 <refname>sd_journal_close</refname>
50                 <refname>sd_journal</refname>
51                 <refname>SD_JOURNAL_LOCAL_ONLY</refname>
52                 <refname>SD_JOURNAL_RUNTIME_ONLY</refname>
53                 <refname>SD_JOURNAL_SYSTEM</refname>
54                 <refname>SD_JOURNAL_CURRENT_USER</refname>
55                 <refpurpose>Open the system journal for reading</refpurpose>
56         </refnamediv>
57
58         <refsynopsisdiv>
59                 <funcsynopsis>
60                         <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
61
62                         <funcprototype>
63                                 <funcdef>int <function>sd_journal_open</function></funcdef>
64                                 <paramdef>sd_journal** <parameter>ret</parameter></paramdef>
65                                 <paramdef>int <parameter>flags</parameter></paramdef>
66                         </funcprototype>
67
68                         <funcprototype>
69                                 <funcdef>int <function>sd_journal_open_directory</function></funcdef>
70                                 <paramdef>sd_journal** <parameter>ret</parameter></paramdef>
71                                 <paramdef>const char* <parameter>path</parameter></paramdef>
72                                 <paramdef>int <parameter>flags</parameter></paramdef>
73                         </funcprototype>
74
75                         <funcprototype>
76                                 <funcdef>int <function>sd_journal_open_files</function></funcdef>
77                                 <paramdef>sd_journal** <parameter>ret</parameter></paramdef>
78                                 <paramdef>const char** <parameter>paths</parameter></paramdef>
79                                 <paramdef>int <parameter>flags</parameter></paramdef>
80                         </funcprototype>
81
82                         <funcprototype>
83                                 <funcdef>void <function>sd_journal_close</function></funcdef>
84                                 <paramdef>sd_journal* <parameter>j</parameter></paramdef>
85                         </funcprototype>
86                 </funcsynopsis>
87         </refsynopsisdiv>
88
89         <refsect1>
90                 <title>Description</title>
91
92                 <para><function>sd_journal_open()</function> opens
93                 the log journal for reading. It will find all journal
94                 files automatically and interleave them automatically
95                 when reading. As first argument it takes a pointer to
96                 a <varname>sd_journal</varname> pointer, which on
97                 success will contain a journal context object. The
98                 second argument is a flags field, which may consist of
99                 the following flags ORed together:
100                 <constant>SD_JOURNAL_LOCAL_ONLY</constant> makes sure
101                 only journal files generated on the local machine will
102                 be opened. <constant>SD_JOURNAL_RUNTIME_ONLY</constant>
103                 makes sure only volatile journal files will be opened,
104                 excluding those which are stored on persistent
105                 storage. <constant>SD_JOURNAL_SYSTEM</constant>
106                 will cause journal files of system services and the
107                 kernel (in opposition to user session processes) to
108                 be opened. <constant>SD_JOURNAL_CURRENT_USER</constant>
109                 will cause journal files of the current user to be
110                 opened. If neither <constant>SD_JOURNAL_SYSTEM</constant>
111                 nor <constant>SD_JOURNAL_CURRENT_USER</constant> are
112                 specified, all journal file types will be opened.</para>
113
114                 <para><function>sd_journal_open_directory()</function>
115                 is similar to <function>sd_journal_open()</function>
116                 but takes an absolute directory path as argument. All
117                 journal files in this directory will be opened and
118                 interleaved automatically. This call also takes a
119                 flags argument, but it must be passed as 0 as no flags
120                 are currently understood for this call.</para>
121
122                 <para><function>sd_journal_open_files()</function>
123                 is similar to <function>sd_journal_open()</function>
124                 but takes a <constant>NULL</constant>-terminated list
125                 of file paths to open. All files will be opened and
126                 interleaved automatically. This call also takes a
127                 flags argument, but it must be passed as 0 as no flags
128                 are currently understood for this call. Please note
129                 that in the case of a live journal, this function is only
130                 useful for debugging, because individual journal files
131                 can be rotated at any moment, and the opening of
132                 specific files is inherently racy.</para>
133
134                 <para><function>sd_journal_close()</function> will
135                 close the journal context allocated with
136                 <function>sd_journal_open()</function> or
137                 <function>sd_journal_open_directory()</function> and
138                 free its resources.</para>
139
140                 <para>When opening the journal only journal files
141                 accessible to the calling user will be opened. If
142                 journal files are not accessible to the caller this
143                 will be silently ignored.</para>
144
145                 <para>See
146                 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
147                 for an example of how to iterate through the journal
148                 after opening it with
149                 <function>sd_journal_open()</function>.</para>
150
151                 <para>A journal context object returned by
152                 <function>sd_journal_open()</function> references a
153                 specific journal entry as <emphasis>current</emphasis> entry,
154                 similar to a file seek index in a classic file system
155                 file, but without absolute positions. It may be
156                 altered with
157                 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
158                 and
159                 <citerefentry><refentrytitle>sd_journal_seek_head</refentrytitle><manvolnum>3</manvolnum></citerefentry>
160                 and related calls. The current entry position may be
161                 exported in <emphasis>cursor</emphasis> strings, as accessible
162                 via
163                 <citerefentry><refentrytitle>sd_journal_get_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Cursor
164                 strings may be used to globally identify a specific
165                 journal entry in a stable way and then later to seek
166                 to it (or if the specific entry is not available
167                 locally, to its closest entry in time)
168                 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
169
170                 <para>Notification of journal changes is available via
171                 <function>sd_journal_get_fd()</function> and related
172                 calls.</para>
173         </refsect1>
174
175         <refsect1>
176                 <title>Return Value</title>
177
178                 <para>The <function>sd_journal_open()</function>,
179                 <function>sd_journal_open_directory()</function>, and
180                 <function>sd_journal_open_files()</function> calls
181                 return 0 on success or a negative errno-style error
182                 code. <function>sd_journal_close()</function> returns
183                 nothing.</para>
184         </refsect1>
185
186         <refsect1>
187                 <title>Notes</title>
188
189                 <para>The <function>sd_journal_open()</function>,
190                 <function>sd_journal_open_directory()</function> and
191                 <function>sd_journal_close()</function> interfaces are
192                 available as a shared library, which can be compiled and
193                 linked to with the
194                 <constant>libsystemd-journal</constant> <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
195                 file.</para>
196         </refsect1>
197
198         <refsect1>
199                 <title>History</title>
200
201                 <para><function>sd_journal_open()</function>,
202                 <function>sd_journal_close()</function>,
203                 <constant>SD_JOURNAL_LOCAL_ONLY</constant>,
204                 <constant>SD_JOURNAL_RUNTIME_ONLY</constant>,
205                 <constant>SD_JOURNAL_SYSTEM_ONLY</constant> were added
206                 in systemd-38.</para>
207
208                 <para><function>sd_journal_open_directory()</function>
209                 was added in systemd-187.</para>
210
211                 <para><constant>SD_JOURNAL_SYSTEM</constant>,
212                 <constant>SD_JOURNAL_CURRENT_USER</constant>,
213                 and <function>sd_journal_open_files()</function>
214                 were added in systemd-205.
215                 <constant>SD_JOURNAL_SYSTEM_ONLY</constant>
216                 was deprecated.</para>
217         </refsect1>
218
219         <refsect1>
220                 <title>See Also</title>
221
222                 <para>
223                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
224                         <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
225                         <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
226                         <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>
227                 </para>
228         </refsect1>
229
230 </refentry>