<?xml version='1.0'?> <!--*-nxml-*-->
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<!-- SPDX-License-Identifier: LGPL-2.1+ -->
-<!--
- This file is part of systemd.
-
- Copyright 2012 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
--->
-
-<refentry id="sd_journal_print">
+<refentry id="sd_journal_print" xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_journal_print</title>
<productname>systemd</productname>
-
- <authorgroup>
- <author>
- <contrib>Developer</contrib>
- <firstname>Lennart</firstname>
- <surname>Poettering</surname>
- <email>lennart@poettering.net</email>
- </author>
- </authorgroup>
</refentryinfo>
<refmeta>
<refname>sd_journal_sendv</refname>
<refname>sd_journal_perror</refname>
<refname>SD_JOURNAL_SUPPRESS_LOCATION</refname>
+ <refname>sd_journal_print_with_location</refname>
+ <refname>sd_journal_printv_with_location</refname>
+ <refname>sd_journal_send_with_location</refname>
+ <refname>sd_journal_sendv_with_location</refname>
+ <refname>sd_journal_perror_with_location</refname>
+
<refpurpose>Submit log entries to the journal</refpurpose>
</refnamediv>
<funcdef>int <function>sd_journal_print</function></funcdef>
<paramdef>int <parameter>priority</parameter></paramdef>
<paramdef>const char *<parameter>format</parameter></paramdef>
- <paramdef>...</paramdef>
+ <paramdef>…</paramdef>
</funcprototype>
<funcprototype>
<funcprototype>
<funcdef>int <function>sd_journal_send</function></funcdef>
<paramdef>const char *<parameter>format</parameter></paramdef>
- <paramdef>...</paramdef>
+ <paramdef>…</paramdef>
</funcprototype>
<funcprototype>
<paramdef>const char *<parameter>message</parameter></paramdef>
</funcprototype>
+ <funcprototype>
+ <funcdef>int <function>sd_journal_print_with_location</function></funcdef>
+ <paramdef>const char *<parameter>file</parameter></paramdef>
+ <paramdef>const char *<parameter>line</parameter></paramdef>
+ <paramdef>const char *<parameter>func</parameter></paramdef>
+ <paramdef>int <parameter>priority</parameter></paramdef>
+ <paramdef>const char *<parameter>format</parameter></paramdef>
+ <paramdef>…</paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_journal_printv_with_location</function></funcdef>
+ <paramdef>int <parameter>priority</parameter></paramdef>
+ <paramdef>const char *<parameter>file</parameter></paramdef>
+ <paramdef>const char *<parameter>line</parameter></paramdef>
+ <paramdef>const char *<parameter>func</parameter></paramdef>
+ <paramdef>const char *<parameter>format</parameter></paramdef>
+ <paramdef>va_list <parameter>ap</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_journal_send_with_location</function></funcdef>
+ <paramdef>const char *<parameter>file</parameter></paramdef>
+ <paramdef>const char *<parameter>line</parameter></paramdef>
+ <paramdef>const char *<parameter>func</parameter></paramdef>
+ <paramdef>const char *<parameter>format</parameter></paramdef>
+ <paramdef>…</paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_journal_sendv_with_location</function></funcdef>
+ <paramdef>const char *<parameter>file</parameter></paramdef>
+ <paramdef>const char *<parameter>line</parameter></paramdef>
+ <paramdef>const char *<parameter>func</parameter></paramdef>
+ <paramdef>const struct iovec *<parameter>iov</parameter></paramdef>
+ <paramdef>int <parameter>n</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>int <function>sd_journal_perror_with_location</function></funcdef>
+ <paramdef>const char *<parameter>file</parameter></paramdef>
+ <paramdef>const char *<parameter>line</parameter></paramdef>
+ <paramdef>const char *<parameter>func</parameter></paramdef>
+ <paramdef>const char *<parameter>message</parameter></paramdef>
+ </funcprototype>
</funcsynopsis>
</refsynopsisdiv>
journal. The first argument is a priority value. This is followed by a format string and its parameters, similar to
<citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> or
<citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
+ Note that currently the resulting message will be truncated to <constant>LINE_MAX - 8</constant>.
The priority value is one of <constant>LOG_EMERG</constant>, <constant>LOG_ALERT</constant>,
<constant>LOG_CRIT</constant>, <constant>LOG_ERR</constant>, <constant>LOG_WARNING</constant>,
<constant>LOG_NOTICE</constant>, <constant>LOG_INFO</constant>, <constant>LOG_DEBUG</constant>, as defined in
project='man-pages'><refentrytitle>readv</refentrytitle><manvolnum>3</manvolnum></citerefentry> for details)
instead of the format string. Each structure should reference one field of the entry to submit. The second argument
specifies the number of structures in the array. <function>sd_journal_sendv()</function> is particularly useful to
- submit binary objects to the journal where that is necessary. Note that this function wil not strip trailing
+ submit binary objects to the journal where that is necessary. Note that this function will not strip trailing
whitespace of the passed fields, but passes the specified data along unmodified. This is different from both
<function>sd_journal_print()</function> and <function>sd_journal_send()</function> described above, which are based
on format strings, and do strip trailing whitespace.</para>
"PRIORITY=%i", LOG_INFO,
NULL);</programlisting>
- <para>Note that these calls implicitly add fields for the source
- file, function name and code line where invoked. This is
- implemented with macros. If this is not desired, it can be turned
- off by defining SD_JOURNAL_SUPPRESS_LOCATION before including
- <filename>sd-journal.h</filename>.</para>
+ <para>Note that these calls implicitly add fields for the source file, function name and code line where
+ invoked. This is implemented with macros. If this is not desired, it can be turned off by defining
+ <constant>SD_JOURNAL_SUPPRESS_LOCATION</constant> before including <filename>sd-journal.h</filename>.
+ </para>
+
+ <para><function>sd_journal_print_with_location</function>,
+ <function>sd_journal_printv_with_location</function>, <function>sd_journal_send_with_location</function>,
+ <function>sd_journal_sendv_with_location</function>, and
+ <function>sd_journal_perror_with_location</function> are similar to their counterparts without
+ <literal>_with_location</literal>, but accept additional parameters to explicitly set the source file
+ name, function, and line. Those arguments must contain valid journal entries including the variable name,
+ e.g. <literal>CODE_FILE=src/foo.c</literal>, <literal>CODE_LINE=666</literal>,
+ <literal>CODE_FUNC=myfunc</literal>. These variants are primarily useful when writing custom wrappers,
+ for example in bindings for a different language.</para>
<para><citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
and <function>sd_journal_print()</function> may
<refsect1>
<title>Return Value</title>
- <para>The four calls return 0 on success or a negative errno-style
- error code. The
+ <para>The ten functions return 0 on success or a negative errno-style error code. The
<citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
variable itself is not altered.</para>
</refsect1>
<refsect1>
- <title>Async signal safety</title>
- <para><function>sd_journal_sendv()</function> is "async signal
- safe" in the meaning of
- <citerefentry project='man-pages'><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
+ <title>Thread safety</title>
+
+ <xi:include href="threads-aware.xml" xpointer="safe"/>
+
+ <para><function>sd_journal_sendv()</function> and <function>sd_journal_sendv_with_location()</function>
+ are "async signal safe" in the meaning of
+ <citerefentry project='man-pages'><refentrytitle>signal-safety</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
</para>
<para><function>sd_journal_print</function>,
<function>sd_journal_printv</function>,
- <function>sd_journal_send</function>, and
- <function>sd_journal_perror</function> are
- not async signal safe.</para>
+ <function>sd_journal_send</function>,
+ <function>sd_journal_perror</function>,
+ and their counterparts with <literal>_with_location</literal>
+ are not async signal safe.</para>
</refsect1>
- <refsect1>
- <title>Notes</title>
-
- <para>The <function>sd_journal_print()</function>,
- <function>sd_journal_printv()</function>,
- <function>sd_journal_send()</function> and
- <function>sd_journal_sendv()</function> interfaces are available
- as a shared library, which can be compiled and linked to with the
- <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
- file.</para>
- </refsect1>
+ <xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>