]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_journal_get_realtime_usec.xml
Merge pull request #9193 from keszybz/coverity
[thirdparty/systemd.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 SPDX-License-Identifier: LGPL-2.1+
7
8 This file is part of systemd.
9
10 Copyright 2012 Lennart Poettering
11 -->
12
13 <refentry id="sd_journal_get_realtime_usec"
14 xmlns:xi="http://www.w3.org/2001/XInclude">
15
16 <refentryinfo>
17 <title>sd_journal_get_realtime_usec</title>
18 <productname>systemd</productname>
19
20 <authorgroup>
21 <author>
22 <contrib>Developer</contrib>
23 <firstname>Lennart</firstname>
24 <surname>Poettering</surname>
25 <email>lennart@poettering.net</email>
26 </author>
27 </authorgroup>
28 </refentryinfo>
29
30 <refmeta>
31 <refentrytitle>sd_journal_get_realtime_usec</refentrytitle>
32 <manvolnum>3</manvolnum>
33 </refmeta>
34
35 <refnamediv>
36 <refname>sd_journal_get_realtime_usec</refname>
37 <refname>sd_journal_get_monotonic_usec</refname>
38 <refpurpose>Read timestamps from the current journal entry</refpurpose>
39 </refnamediv>
40
41 <refsynopsisdiv>
42 <funcsynopsis>
43 <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
44
45 <funcprototype>
46 <funcdef>int <function>sd_journal_get_realtime_usec</function></funcdef>
47 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
48 <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
49 </funcprototype>
50
51 <funcprototype>
52 <funcdef>int <function>sd_journal_get_monotonic_usec</function></funcdef>
53 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
54 <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
55 <paramdef>sd_id128_t *<parameter>boot_id</parameter></paramdef>
56 </funcprototype>
57
58 </funcsynopsis>
59 </refsynopsisdiv>
60
61 <refsect1>
62 <title>Description</title>
63
64 <para><function>sd_journal_get_realtime_usec()</function> gets the
65 realtime (wallclock) timestamp of the current journal entry. It
66 takes two arguments: the journal context object and a pointer to a
67 64-bit unsigned integer to store the timestamp in. The timestamp
68 is in microseconds since the epoch, i.e.
69 <constant>CLOCK_REALTIME</constant>.</para>
70
71 <para><function>sd_journal_get_monotonic_usec()</function> gets
72 the monotonic timestamp of the current journal entry. It takes
73 three arguments: the journal context object, a pointer to a 64-bit
74 unsigned integer to store the timestamp in, as well as a 128-bit
75 ID buffer to store the boot ID of the monotonic timestamp. The
76 timestamp is in microseconds since boot-up of the specific boot,
77 i.e. <constant>CLOCK_MONOTONIC</constant>. Since the monotonic
78 clock begins new with every reboot, it only defines a well-defined
79 point in time when used together with an identifier identifying
80 the boot. See
81 <citerefentry><refentrytitle>sd_id128_get_boot</refentrytitle><manvolnum>3</manvolnum></citerefentry>
82 for more information. If the boot ID parameter is passed
83 <constant>NULL</constant>, the function will fail if the monotonic
84 timestamp of the current entry is not of the current system
85 boot.</para>
86
87 <para>Note that these functions will not work before
88 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
89 (or related call) has been called at least
90 once, in order to position the read pointer at a valid entry.</para>
91 </refsect1>
92
93 <refsect1>
94 <title>Return Value</title>
95
96 <para><function>sd_journal_get_realtime_usec()</function> and
97 <function>sd_journal_get_monotonic_usec()</function> returns 0 on
98 success or a negative errno-style error code. If the boot ID
99 parameter was passed <constant>NULL</constant> and the monotonic
100 timestamp of the current journal entry is not of the current
101 system boot, <constant>-ESTALE</constant> is returned by
102 <function>sd_journal_get_monotonic_usec()</function>.</para>
103 </refsect1>
104
105 <xi:include href="libsystemd-pkgconfig.xml" />
106
107 <refsect1>
108 <title>See Also</title>
109
110 <para>
111 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
112 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
113 <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
114 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
115 <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
116 <citerefentry><refentrytitle>sd_id128_get_boot</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
117 <citerefentry><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
118 <citerefentry><refentrytitle>sd_journal_get_cutoff_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>
119 </para>
120 </refsect1>
121
122 </refentry>