]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd-daemon.xml
journald: splitt of syslog protocol support into its own file
[thirdparty/systemd.git] / man / sd-daemon.xml
CommitLineData
f9378423
LP
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 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
f9378423
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
f9378423 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
f9378423
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
24<refentry id="sd-daemon">
25
26 <refentryinfo>
27 <title>sd-daemon</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd-daemon</refentrytitle>
cb07866b 42 <manvolnum>3</manvolnum>
f9378423
LP
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd-daemon</refname>
976c46f8
LP
47 <refname>SD_EMERG</refname>
48 <refname>SD_ALERT</refname>
49 <refname>SD_CRIT</refname>
50 <refname>SD_ERR</refname>
51 <refname>SD_WARNING</refname>
52 <refname>SD_NOTICE</refname>
53 <refname>SD_INFO</refname>
54 <refname>SD_DEBUG</refname>
f9378423
LP
55 <refpurpose>Reference implementation of APIs for
56 new-style daemons</refpurpose>
57 </refnamediv>
58
59 <refsynopsisdiv>
60 <funcsynopsis>
a822cbfa 61 <funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
f9378423 62 </funcsynopsis>
7712ea6d
LP
63
64 <cmdsynopsis>
65 <command>pkg-config --cflags --libs libsystemd-daemon</command>
66 </cmdsynopsis>
67
f9378423
LP
68 </refsynopsisdiv>
69
70 <refsect1>
71 <title>Description</title>
72
73 <para><filename>sd-daemon.c</filename> and
74 <filename>sd-daemon.h</filename> provide a reference
75 implementation of various APIs for new-style daemons,
76 as implemented by the
f3e219a2 77 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
f9378423
LP
78 init system.</para>
79
80 <para>See
81 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
82 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
83 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
84 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>
85 for more information about the functions
86 implemented. In addition to these functions a couple
87 of logging prefixes are defined as macros:</para>
88
89 <programlisting>#define SD_EMERG "&lt;0&gt;" /* system is unusable */
90#define SD_ALERT "&lt;1&gt;" /* action must be taken immediately */
91#define SD_CRIT "&lt;2&gt;" /* critical conditions */
92#define SD_ERR "&lt;3&gt;" /* error conditions */
93#define SD_WARNING "&lt;4&gt;" /* warning conditions */
94#define SD_NOTICE "&lt;5&gt;" /* normal but significant condition */
95#define SD_INFO "&lt;6&gt;" /* informational */
96#define SD_DEBUG "&lt;7&gt;" /* debug-level messages */</programlisting>
97
98 <para>These prefixes are intended to be used in
99 conjunction with STDERR-based logging as implemented
100 by systemd. If a systemd service definition file is
101 configured with <varname>StandardError=syslog</varname>
102 or <varname>StandardError=kmsg</varname> these
103 prefixes can be used to encode a log level in lines
104 printed. This is similar to the kernel
105 <function>printk()</function>-style logging. See
106 <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
107 for more information.</para>
108
109 <para>The log levels are identical to
110 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
111 log level system. To use these prefixes simply prefix
112 every line with one of these strings. A line that is
113 not prefixed will be logged at the default log level
114 SD_INFO.</para>
115
116 <example>
117 <title>Hello World</title>
118
119 <para>A daemon may log with the log level
120 NOTICE by issuing this call:</para>
121
122 <programlisting>fprintf(stderr, SD_NOTICE "Hello World!\n");</programlisting>
123 </example>
124 </refsect1>
125
126 <refsect1>
127 <title>Notes</title>
128
129 <para>These interfaces are provided by the reference
130 implementation of APIs for new-style daemons and
131 distributed with the systemd package. The algorithms
132 they implement are simple, and can easily be
133 reimplemented in daemons if it is important to support
134 this interface without using the reference
135 implementation. See the respective function man pages
136 for details.</para>
137
138 <para>In addition, for details about the algorithms
139 check the liberally licensed reference implementation
140 sources:
a26c9cc6
MB
141 <ulink url="http://cgit.freedesktop.org/systemd/systemd/plain/src/sd-daemon.c"/>
142 resp. <ulink url="http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h"/></para>
f9378423
LP
143
144 <para>These APIs are implemented in the reference
71e6c1cf
LP
145 implementation's <filename>sd-daemon.c</filename> and
146 <filename>sd-daemon.h</filename> files. These
147 interfaces are available as shared library, which can
148 be compiled and linked to with the
149 <literal>libsystemd-daemon</literal>
150 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
151 file. Alternatively, applications consuming these APIs
152 may copy the implementation into their source tree,
153 either verbatim or in excerpts.</para>
f9378423
LP
154
155 <para>The functions directly related to new-style
156 daemons become NOPs when -DDISABLE_SYSTEMD is set
71e6c1cf
LP
157 during compilation and the reference implementation is
158 used as drop-in files. In addition, if
f9378423 159 <filename>sd-daemon.c</filename> is compiled on
af62c704 160 non-Linux systems they become NOPs.</para>
f9378423
LP
161 </refsect1>
162
163 <refsect1>
164 <title>See Also</title>
165 <para>
160cd5c9 166 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
f9378423
LP
167 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
168 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
169 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
170 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
f9378423
LP
172 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
173 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e62e6670 174 <citerefentry><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
cb07866b 175 <citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
7712ea6d 176 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
f9378423
LP
177 </para>
178 </refsect1>
179
180</refentry>