chiark / gitweb /
bus-proxy: no need to negate error codes, log_error_errno() already does it
[elogind.git] / man / sd_journal_get_realtime_usec.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_get_realtime_usec">
25
26   <refentryinfo>
27     <title>sd_journal_get_realtime_usec</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_get_realtime_usec</refentrytitle>
42     <manvolnum>3</manvolnum>
43   </refmeta>
44
45   <refnamediv>
46     <refname>sd_journal_get_realtime_usec</refname>
47     <refname>sd_journal_get_monotonic_usec</refname>
48     <refpurpose>Read timestamps from the current journal entry</refpurpose>
49   </refnamediv>
50
51   <refsynopsisdiv>
52     <funcsynopsis>
53       <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
54
55       <funcprototype>
56         <funcdef>int <function>sd_journal_get_realtime_usec</function></funcdef>
57         <paramdef>sd_journal *<parameter>j</parameter></paramdef>
58         <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
59       </funcprototype>
60
61       <funcprototype>
62         <funcdef>int <function>sd_journal_get_monotonic_usec</function></funcdef>
63         <paramdef>sd_journal *<parameter>j</parameter></paramdef>
64         <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
65         <paramdef>sd_id128_t *<parameter>boot_id</parameter></paramdef>
66       </funcprototype>
67
68     </funcsynopsis>
69   </refsynopsisdiv>
70
71   <refsect1>
72     <title>Description</title>
73
74     <para><function>sd_journal_get_realtime_usec()</function> gets the
75     realtime (wallclock) timestamp of the current journal entry. It
76     takes two arguments: the journal context object and a pointer to a
77     64-bit unsigned integer to store the timestamp in. The timestamp
78     is in microseconds since the epoch, i.e.
79     <constant>CLOCK_REALTIME</constant>.</para>
80
81     <para><function>sd_journal_get_monotonic_usec()</function> gets
82     the monotonic timestamp of the current journal entry. It takes
83     three arguments: the journal context object, a pointer to a 64-bit
84     unsigned integer to store the timestamp in, as well as a 128-bit
85     ID buffer to store the boot ID of the monotonic timestamp. The
86     timestamp is in microseconds since boot-up of the specific boot,
87     i.e. <constant>CLOCK_MONOTONIC</constant>. Since the monotonic
88     clock begins new with every reboot, it only defines a well-defined
89     point in time when used together with an identifier identifying
90     the boot. See
91     <citerefentry><refentrytitle>sd_id128_get_boot</refentrytitle><manvolnum>3</manvolnum></citerefentry>
92     for more information. If the boot ID parameter is passed
93     <constant>NULL</constant>, the function will fail if the monotonic
94     timestamp of the current entry is not of the current system
95     boot.</para>
96
97     <para>Note that these functions will not work before
98     <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
99     (or related call) has been called at least
100     once, in order to position the read pointer at a valid entry.</para>
101   </refsect1>
102
103   <refsect1>
104     <title>Return Value</title>
105
106     <para><function>sd_journal_get_realtime_usec()</function> and
107     <function>sd_journal_get_monotonic_usec()</function> returns 0 on
108     success or a negative errno-style error code. If the boot ID
109     parameter was passed <constant>NULL</constant> and the monotonic
110     timestamp of the current journal entry is not of the current
111     system boot, <constant>-ESTALE</constant> is returned by
112     <function>sd_journal_get_monotonic_usec()</function>.</para>
113   </refsect1>
114
115   <refsect1>
116     <title>Notes</title>
117
118     <para>The <function>sd_journal_get_realtime_usec()</function> and
119     <function>sd_journal_get_monotonic_usec()</function> interfaces
120     are available as a shared library, which can be compiled and
121     linked to with the
122     <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
123     file.</para>
124   </refsect1>
125
126   <refsect1>
127     <title>See Also</title>
128
129     <para>
130       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
131       <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
132       <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133       <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134       <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135       <citerefentry><refentrytitle>sd_id128_get_boot</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
136       <citerefentry><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
137       <citerefentry><refentrytitle>sd_journal_get_cutoff_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>
138     </para>
139   </refsect1>
140
141 </refentry>