]>
Commit | Line | Data |
---|---|---|
3bb55eee LP |
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> | |
976c46f8 LP |
49 | <refname>sd_journal</refname> |
50 | <refname>SD_JOURNAL_LOCAL_ONLY</refname> | |
51 | <refname>SD_JOURNAL_RUNTIME_ONLY</refname> | |
52 | <refname>SD_JOURNAL_SYSTEM_ONLY</refname> | |
3bb55eee LP |
53 | <refpurpose>Open the system journal for reading</refpurpose> |
54 | </refnamediv> | |
55 | ||
56 | <refsynopsisdiv> | |
57 | <funcsynopsis> | |
58 | <funcsynopsisinfo>#include <systemd/sd-journal.h></funcsynopsisinfo> | |
59 | ||
60 | <funcprototype> | |
61 | <funcdef>int <function>sd_journal_open</function></funcdef> | |
62 | <paramdef>sd_journal** <parameter>ret</parameter></paramdef> | |
63 | <paramdef>int <parameter>flags</parameter></paramdef> | |
64 | </funcprototype> | |
65 | ||
66 | <funcprototype> | |
67 | <funcdef>int <function>sd_journal_open_directory</function></funcdef> | |
68 | <paramdef>sd_journal** <parameter>ret</parameter></paramdef> | |
69 | <paramdef>const char* <parameter>path</parameter></paramdef> | |
70 | <paramdef>int <parameter>flags</parameter></paramdef> | |
71 | </funcprototype> | |
72 | ||
73 | <funcprototype> | |
486aad23 | 74 | <funcdef>void <function>sd_journal_close</function></funcdef> |
3bb55eee LP |
75 | <paramdef>sd_journal* <parameter>j</parameter></paramdef> |
76 | </funcprototype> | |
77 | </funcsynopsis> | |
78 | </refsynopsisdiv> | |
79 | ||
80 | <refsect1> | |
81 | <title>Description</title> | |
82 | ||
bb31a4ac | 83 | <para><function>sd_journal_open()</function> opens |
3bb55eee LP |
84 | the log journal for reading. It will find all journal |
85 | files automatically and interleave them automatically | |
86 | when reading. As first argument it takes a pointer to | |
87 | a <literal>sd_journal</literal> pointer, which on | |
976c46f8 | 88 | success will contain journal context object afterwards. The |
3bb55eee LP |
89 | second argument is a flags field, which may consist of |
90 | the following flags ORed together: | |
91 | <literal>SD_JOURNAL_LOCAL_ONLY</literal> makes sure | |
92 | only journal files generated on the local machine will | |
93 | be opened. <literal>SD_JOURNAL_RUNTIME_ONLY</literal> | |
94 | makes sure only volatile journal files will be opened, | |
49f43d5f | 95 | excluding those which are stored on persistent |
67c3cf4f | 96 | storage. <literal>SD_JOURNAL_SYSTEM_ONLY</literal> |
3bb55eee LP |
97 | will ensure that only journal files of system services |
98 | and the kernel (in opposition to user session processes) will | |
99 | be opened.</para> | |
100 | ||
101 | <para><function>sd_journal_open_directory()</function> | |
102 | is similar to <function>sd_journal_open()</function> | |
103 | but takes an absolute directory path as argument. All | |
104 | journal files in this directory will be opened and | |
105 | interleaved automatically. This call also takes a | |
106 | flags argument, but it must be passed as 0 as no flags | |
107 | are currently understood for this call.</para> | |
108 | ||
109 | <para><function>sd_journal_close()</function> will | |
110 | close the journal context allocated with | |
111 | <function>sd_journal_open()</function> or | |
112 | <function>sd_journal_open_directory()</function> and | |
113 | free its resources.</para> | |
114 | ||
115 | <para>When opening the journal only journal files | |
116 | accessible to the calling user will be opened. If | |
117 | journal files are not accessible to the caller this | |
118 | will be silently ignored.</para> | |
67c3cf4f LP |
119 | |
120 | <para>See | |
121 | <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
122 | for an example how to iterate through the journal | |
bb31a4ac | 123 | after opening it with |
67c3cf4f | 124 | <function>sd_journal_open()</function>.</para> |
4a010f4e LP |
125 | |
126 | <para>A journal context object returned by | |
127 | <function>sd_journal_open()</function> references a | |
128 | specific journal entry as <emphasis>current</emphasis> entry, | |
129 | similar to a file seek index in a classic file system | |
130 | file, but without absolute positions. It may be | |
131 | altered with | |
132 | <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
133 | and | |
134 | <citerefentry><refentrytitle>sd_journal_seek_head</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
135 | and related calls. The current entry position may be | |
136 | exported in <emphasis>cursor</emphasis> strings, as accessible | |
137 | via | |
138 | <citerefentry><refentrytitle>sd_journal_get_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Cursor | |
139 | strings may be used to globally identify a specific | |
140 | journal entry in a stable way and then later to seek | |
141 | to it (or if the specific entry is not available | |
142 | locally, to its closest entry in time) | |
143 | <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> | |
6ca9571e LP |
144 | |
145 | <para>Notification of journal changes is available via | |
146 | <function>sd_journal_get_fd()</function> and related | |
147 | calls.</para> | |
3bb55eee LP |
148 | </refsect1> |
149 | ||
150 | <refsect1> | |
151 | <title>Return Value</title> | |
152 | ||
153 | <para>The <function>sd_journal_open()</function> and | |
154 | <function>sd_journal_open_directory()</function> calls | |
155 | return 0 on success or a negative errno-style error | |
156 | code. <function>sd_journal_close()</function> returns | |
157 | nothing.</para> | |
158 | </refsect1> | |
159 | ||
160 | <refsect1> | |
161 | <title>Notes</title> | |
162 | ||
163 | <para>The <function>sd_journal_open()</function>, | |
164 | <function>sd_journal_open_directory()</function> and | |
165 | <function>sd_journal_close()</function> interfaces are | |
166 | available as shared library, which can be compiled and | |
167 | linked to with the | |
168 | <literal>libsystemd-journal</literal> | |
169 | <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
170 | file.</para> | |
171 | </refsect1> | |
172 | ||
173 | <refsect1> | |
174 | <title>See Also</title> | |
175 | ||
176 | <para> | |
177 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
178 | <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
179 | <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
180 | <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
181 | </para> | |
182 | </refsect1> | |
183 | ||
184 | </refentry> |