man-pages/man3/sd-daemon.3.html
2021-03-31 01:06:50 +01:00

164 lines
4.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SD-DAEMON</TITLE>
</HEAD><BODY>
<H1>SD-DAEMON</H1>
Section: sd-daemon (3)<BR>Updated: <BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
sd-daemon, SD_EMERG, SD_ALERT, SD_CRIT, SD_ERR, SD_WARNING, SD_NOTICE, SD_INFO, SD_DEBUG - APIs for new-style daemons
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<B>
</B><PRE>
#include &lt;<A HREF="file:///usr/include/systemd/sd-daemon.h">systemd/sd-daemon.h</A>&gt;
</PRE>
<DL COMPACT>
<DT id="1">
<B>pkg-config --cflags --libs libsystemd</B>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
<DD>sd-daemon.h
provides APIs for new-style daemons, as implemented by the
<B><A HREF="/cgi-bin/man/man2html?1+systemd">systemd</A></B>(1)
service manager.
<P>
See
<B><A HREF="/cgi-bin/man/man2html?3+sd_listen_fds">sd_listen_fds</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_notify">sd_notify</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_booted">sd_booted</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_is_fifo">sd_is_fifo</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_watchdog_enabled">sd_watchdog_enabled</A></B>(3)
for more information about the functions implemented. In addition to these functions, a couple of logging prefixes are defined as macros:
<P>
<DL COMPACT><DT id="2"><DD>
<PRE>
#define SD_EMERG &quot;&lt;0&gt;&quot; /* system is unusable */
#define SD_ALERT &quot;&lt;1&gt;&quot; /* action must be taken immediately */
#define SD_CRIT &quot;&lt;2&gt;&quot; /* critical conditions */
#define SD_ERR &quot;&lt;3&gt;&quot; /* error conditions */
#define SD_WARNING &quot;&lt;4&gt;&quot; /* warning conditions */
#define SD_NOTICE &quot;&lt;5&gt;&quot; /* normal but significant condition */
#define SD_INFO &quot;&lt;6&gt;&quot; /* informational */
#define SD_DEBUG &quot;&lt;7&gt;&quot; /* debug-level messages */
</PRE>
</DL>
<P>
These prefixes are intended to be used in conjunction with stderr-based logging (or stdout-based logging) as implemented by systemd. If a systemd service definition file is configured with
<I>StandardError=journal</I>,
<I>StandardError=syslog</I>
or
<I>StandardError=kmsg</I>
(and similar with
<I>StandardOutput=</I>), these prefixes can be used to encode a log level in lines printed. This is similar to the kernel
<B>printk()</B>-style logging. See
<B><A HREF="/cgi-bin/man/man2html?2+klogctl">klogctl</A></B>(2)
for more information.
<P>
The log levels are identical to
<B><A HREF="/cgi-bin/man/man2html?3+syslog">syslog</A></B>(3)'s log level system. To use these prefixes simply prefix every line with one of these strings. A line that is not prefixed will be logged at the default log level SD_INFO.
<P>
<B>Example&nbsp;1.&nbsp;Hello World</B>
<P>
A daemon may log with the log level NOTICE by issuing this call:
<P>
<DL COMPACT><DT id="3"><DD>
<PRE>
fprintf(stderr, SD_NOTICE &quot;Hello World!\n&quot;);
</PRE>
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>NOTES</H2>
<P>
These APIs are implemented as a shared library, which can be compiled and linked to with the
<B>libsystemd</B>&nbsp;<B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
file.
<A NAME="lbAF">&nbsp;</A>
<H2>SEE ALSO</H2>
<P>
<B><A HREF="/cgi-bin/man/man2html?1+systemd">systemd</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?3+sd_listen_fds">sd_listen_fds</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_notify">sd_notify</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_booted">sd_booted</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_is_fifo">sd_is_fifo</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_watchdog_enabled">sd_watchdog_enabled</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?7+daemon">daemon</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?5+systemd.service">systemd.service</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?5+systemd.socket">systemd.socket</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?3+fprintf">fprintf</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="4"><A HREF="#lbAB">NAME</A><DD>
<DT id="5"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="6"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="7"><A HREF="#lbAE">NOTES</A><DD>
<DT id="8"><A HREF="#lbAF">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:55 GMT, March 31, 2021
</BODY>
</HTML>