mirror of
https://git.proxmox.com/git/systemd
synced 2025-08-04 10:07:14 +00:00
95 lines
8.5 KiB
HTML
95 lines
8.5 KiB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd-daemon</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
|
||
a.headerlink {
|
||
color: #c60f0f;
|
||
font-size: 0.8em;
|
||
padding: 0 4px 0 4px;
|
||
text-decoration: none;
|
||
visibility: hidden;
|
||
}
|
||
|
||
a.headerlink:hover {
|
||
background-color: #c60f0f;
|
||
color: white;
|
||
}
|
||
|
||
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
|
||
visibility: visible;
|
||
}
|
||
</style><a href="index.html">Index </a>·
|
||
<a href="systemd.directives.html">Directives </a>·
|
||
<a href="../python-systemd/index.html">Python </a>·
|
||
<a href="../libudev/index.html">libudev </a>·
|
||
<a href="../libudev/index.html">gudev </a><span style="float:right">systemd 204</span><hr><div class="refentry"><a name="sd-daemon"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd-daemon, SD_EMERG, SD_ALERT, SD_CRIT, SD_ERR, SD_WARNING, SD_NOTICE, SD_INFO, SD_DEBUG — Reference implementation of APIs for
|
||
new-style daemons</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <systemd/sd-daemon.h></pre></div><div class="cmdsynopsis"><p><code class="command">pkg-config --cflags --libs libsystemd-daemon</code> </p></div></div><div class="refsect1"><a name="idm259783673520"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="filename">sd-daemon.c</code> and
|
||
<code class="filename">sd-daemon.h</code> provide a reference
|
||
implementation of various APIs for new-style daemons,
|
||
as implemented by the
|
||
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>
|
||
init system.</p><p>See
|
||
<a href="sd_listen_fds.html"><span class="citerefentry"><span class="refentrytitle">sd_listen_fds</span>(3)</span></a>,
|
||
<a href="sd_notify.html"><span class="citerefentry"><span class="refentrytitle">sd_notify</span>(3)</span></a>,
|
||
<a href="sd_booted.html"><span class="citerefentry"><span class="refentrytitle">sd_booted</span>(3)</span></a>,
|
||
<a href="sd_is_fifo.html"><span class="citerefentry"><span class="refentrytitle">sd_is_fifo</span>(3)</span></a>
|
||
for more information about the functions
|
||
implemented. In addition to these functions a couple
|
||
of logging prefixes are defined as macros:</p><pre class="programlisting">#define SD_EMERG "<0>" /* system is unusable */
|
||
#define SD_ALERT "<1>" /* action must be taken immediately */
|
||
#define SD_CRIT "<2>" /* critical conditions */
|
||
#define SD_ERR "<3>" /* error conditions */
|
||
#define SD_WARNING "<4>" /* warning conditions */
|
||
#define SD_NOTICE "<5>" /* normal but significant condition */
|
||
#define SD_INFO "<6>" /* informational */
|
||
#define SD_DEBUG "<7>" /* debug-level messages */</pre><p>These prefixes are intended to be used in
|
||
conjunction with STDERR-based logging as implemented
|
||
by systemd. If a systemd service definition file is
|
||
configured with <code class="varname">StandardError=syslog</code>
|
||
or <code class="varname">StandardError=kmsg</code> these
|
||
prefixes can be used to encode a log level in lines
|
||
printed. This is similar to the kernel
|
||
<code class="function">printk()</code>-style logging. See
|
||
<a href="klogctl.html"><span class="citerefentry"><span class="refentrytitle">klogctl</span>(2)</span></a>
|
||
for more information.</p><p>The log levels are identical to
|
||
<a href="syslog.html"><span class="citerefentry"><span class="refentrytitle">syslog</span>(3)</span></a>'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><div class="example"><a name="idm259782027536"></a><p class="title"><b>Example 1. Hello World</b></p><div class="example-contents"><p>A daemon may log with the log level
|
||
NOTICE by issuing this call:</p><pre class="programlisting">fprintf(stderr, SD_NOTICE "Hello World!\n");</pre></div></div><br class="example-break"></div><div class="refsect1"><a name="idm259782025408"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p>These interfaces are provided by the reference
|
||
implementation of APIs for new-style daemons and
|
||
distributed with the systemd package. The algorithms
|
||
they implement are simple, and can easily be
|
||
reimplemented in daemons if it is important to support
|
||
this interface without using the reference
|
||
implementation. See the respective function man pages
|
||
for details.</p><p>In addition, for details about the algorithms
|
||
check the liberally licensed reference implementation
|
||
sources:
|
||
<a class="ulink" href="http://cgit.freedesktop.org/systemd/systemd/plain/src/libsystemd-daemon/sd-daemon.c" target="_top">http://cgit.freedesktop.org/systemd/systemd/plain/src/libsystemd-daemon/sd-daemon.c</a>
|
||
and <a class="ulink" href="http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h" target="_top">http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h</a></p><p>These APIs are implemented in the reference
|
||
implementation's <code class="filename">sd-daemon.c</code> and
|
||
<code class="filename">sd-daemon.h</code> files. These
|
||
interfaces are available as shared library, which can
|
||
be compiled and linked to with the
|
||
<code class="literal">libsystemd-daemon</code>
|
||
<a href="pkg-config.html"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
|
||
file. Alternatively, applications consuming these APIs
|
||
may copy the implementation into their source tree,
|
||
either verbatim or in excerpts.</p><p>The functions directly related to new-style
|
||
daemons become NOPs when -DDISABLE_SYSTEMD is set
|
||
during compilation and the reference implementation is
|
||
used as drop-in files. In addition, if
|
||
<code class="filename">sd-daemon.c</code> is compiled on
|
||
non-Linux systems they become NOPs.</p></div><div class="refsect1"><a name="idm259783768736"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
|
||
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
|
||
<a href="sd_listen_fds.html"><span class="citerefentry"><span class="refentrytitle">sd_listen_fds</span>(3)</span></a>,
|
||
<a href="sd_notify.html"><span class="citerefentry"><span class="refentrytitle">sd_notify</span>(3)</span></a>,
|
||
<a href="sd_booted.html"><span class="citerefentry"><span class="refentrytitle">sd_booted</span>(3)</span></a>,
|
||
<a href="sd_is_fifo.html"><span class="citerefentry"><span class="refentrytitle">sd_is_fifo</span>(3)</span></a>,
|
||
<a href="daemon.html"><span class="citerefentry"><span class="refentrytitle">daemon</span>(7)</span></a>,
|
||
<a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
|
||
<a href="systemd.socket.html"><span class="citerefentry"><span class="refentrytitle">systemd.socket</span>(5)</span></a>,
|
||
<a href="fprintf.html"><span class="citerefentry"><span class="refentrytitle">fprintf</span>(3)</span></a>,
|
||
<a href="sd-readahead.html"><span class="citerefentry"><span class="refentrytitle">sd-readahead</span>(3)</span></a>,
|
||
<a href="pkg-config.html"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
|
||
</p></div></div></body></html>
|