chiark / gitweb /
man: ipv4 link-local
[elogind.git] / man / sd_journal_print.xml
index dfe99192e7e7a28e5fd7b61532a8d4cd4aabf702..c6f204b8c6cf455490c9a501b765cf01ed45dd6d 100644 (file)
@@ -47,6 +47,7 @@
                 <refname>sd_journal_printv</refname>
                 <refname>sd_journal_send</refname>
                 <refname>sd_journal_sendv</refname>
+                <refname>sd_journal_perror</refname>
                 <refname>SD_JOURNAL_SUPPRESS_LOCATION</refname>
                 <refpurpose>Submit log entries to the journal</refpurpose>
         </refnamediv>
                                 <paramdef>int <parameter>n</parameter></paramdef>
                         </funcprototype>
 
+                        <funcprototype>
+                                <funcdef>int <function>sd_journal_perror</function></funcdef>
+                                <paramdef>const char* <parameter>message</parameter></paramdef>
+                        </funcprototype>
+
                 </funcsynopsis>
         </refsynopsisdiv>
 
                 or
                 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>. The
                 priority value is one of
-                <literal>LOG_EMERG</literal>,
-                <literal>LOG_ALERT</literal>,
-                <literal>LOG_CRIT</literal>,
-                <literal>LOG_ERR</literal>,
-                <literal>LOG_WARNING</literal>,
-                <literal>LOG_NOTICE</literal>,
-                <literal>LOG_INFO</literal>,
-                <literal>LOG_DEBUG</literal>, as defined in
+                <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
                 <filename>syslog.h</filename>, see
                 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
                 for details. It is recommended to use this call to
                 <para><function>sd_journal_printv()</function> is
                 similar to <function>sd_journal_print()</function> but
                 takes a variable argument list encapsulated in an
-                object of type <literal>va_list</literal> (see
+                object of type <varname>va_list</varname> (see
                 <citerefentry><refentrytitle>stdarg</refentrytitle><manvolnum>3</manvolnum></citerefentry>
                 for more information) instead of the format string. It
-                is otherwise equivalent in behaviour.</para>
+                is otherwise equivalent in behavior.</para>
 
                 <para><function>sd_journal_send()</function> may be
                 used to submit structured log entries to the system
                 journal. It takes a series of format strings, each
                 immediately followed by their associated parameters,
-                terminated by NULL. The strings passed should be of
+                terminated by <constant>NULL</constant>. The strings passed should be of
                 the format <literal>VARIABLE=value</literal>. The
-                variable name must be in uppercase and consist only
-                of characters, numbers and underscores, and may not
-                begin with an underscore. The value can be of any size
-                and format. It is highly recommended to submit
-                text strings formatted in the UTF-8 character encoding
-                only, and submit binary fields only when formatting in
-                UTf-8 strings is not sensible. A number of well known
-                fields are defined, see
+                variable name must be in uppercase and consist only of
+                characters, numbers and underscores, and may not begin
+                with an underscore. (All assignments that do not
+                follow this syntax will be ignored.) The value can be
+                of any size and format. It is highly recommended to
+                submit text strings formatted in the UTF-8 character
+                encoding only, and submit binary fields only when
+                formatting in UTF-8 strings is not sensible. A number
+                of well known fields are defined, see
                 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
                 for details, but additional application defined fields
-                may be used.</para>
+                may be used. A variable may be assigned more than one
+                value per entry.</para>
 
                 <para><function>sd_journal_sendv()</function> is
                 similar to <function>sd_journal_send()</function> but
-                takes an array of <literal>struct iovec</literal> (as
+                takes an array of <varname>struct iovec</varname> (as
                 defined in <filename>uio.h</filename>, see
                 <citerefentry><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
+                structures in the array.
+                <function>sd_journal_sendv()</function> is
                 particularly useful to submit binary objects to the
                 journal where that is necessary.</para>
 
+                <para><function>sd_journal_perror()</function> is a
+                similar to
+                <citerefentry><refentrytitle>perror</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+                and writes a message to the journal that consists of
+                the passed string, suffixed with ": " and a human
+                readable representation of the current error code
+                stored in
+                <citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If
+                the message string is passed as <constant>NULL</constant> or empty string,
+                only the error string representation will be written,
+                prefixed with nothing. An additional journal field
+                ERRNO= is included in the entry containing the numeric
+                error code formatted as decimal string. The log
+                priority used is <constant>LOG_ERR</constant> (3).</para>
+
                 <para>Note that <function>sd_journal_send()</function>
                 is a wrapper around
                 <function>sd_journal_sendv()</function> to make it
@@ -166,12 +189,12 @@ sd_journal_send("MESSAGE=Hello World, this is PID %lu!", (unsigned long) getpid(
                 <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
+                not desired, it can be turned off by defining
                 SD_JOURNAL_SUPPRESS_LOCATION before including
                 <filename>sd-journal.h</filename>.</para>
 
                 <para><citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-                and and <function>sd_journal_print()</function> may
+                and <function>sd_journal_print()</function> may
                 largely be used interchangeably
                 functionality-wise. However, note that log messages
                 logged via the former take a different path to the
@@ -179,8 +202,8 @@ sd_journal_send("MESSAGE=Hello World, this is PID %lu!", (unsigned long) getpid(
                 chronological ordering between the two streams cannot
                 be guaranteed. Using
                 <function>sd_journal_print()</function> has the
-                benefit of logging source code line, file names, and
-                functions as meta data along all entries, and
+                benefit of logging source code line, filenames, and
+                functions as metadata along all entries, and
                 guaranteeing chronological ordering with structured
                 log entries that are generated via
                 <function>sd_journal_send()</function>. Using
@@ -191,8 +214,23 @@ sd_journal_send("MESSAGE=Hello World, this is PID %lu!", (unsigned long) getpid(
         <refsect1>
                 <title>Return Value</title>
 
-                <para>The four calls return 0 on success or a
-                negative errno-style error code.</para>
+                <para>The four calls return 0 on success or a negative
+                errno-style error code. The
+                <citerefentry><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><refentrytitle>signal</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>
         </refsect1>
 
         <refsect1>
@@ -202,10 +240,9 @@ sd_journal_send("MESSAGE=Hello World, this is PID %lu!", (unsigned long) getpid(
                 <function>sd_journal_printv()</function>,
                 <function>sd_journal_send()</function> and
                 <function>sd_journal_sendv()</function> interfaces
-                are available as shared library, which can be compiled
+                are available as shared library, which can be compiled
                 and linked to with the
-                <literal>libsystemd-journal</literal>
-                <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+                <constant>libsystemd</constant> <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
                 file.</para>
         </refsect1>
 
@@ -217,7 +254,11 @@ sd_journal_send("MESSAGE=Hello World, this is PID %lu!", (unsigned long) getpid(
                         <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>sd_journal_stream_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
                         <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-                        <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+                        <citerefentry><refentrytitle>perror</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+                        <citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+                        <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
+                        <citerefentry><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
+                        <citerefentry><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
                 </para>
         </refsect1>