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">
6 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
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
13 (at your option) any later version.
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
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd-daemon"
25 xmlns:xi="http://www.w3.org/2001/XInclude">
28 <title>sd-daemon</title>
29 <productname>systemd</productname>
33 <contrib>Developer</contrib>
34 <firstname>Lennart</firstname>
35 <surname>Poettering</surname>
36 <email>lennart@poettering.net</email>
42 <refentrytitle>sd-daemon</refentrytitle>
43 <manvolnum>3</manvolnum>
47 <refname>sd-daemon</refname>
48 <refname>SD_EMERG</refname>
49 <refname>SD_ALERT</refname>
50 <refname>SD_CRIT</refname>
51 <refname>SD_ERR</refname>
52 <refname>SD_WARNING</refname>
53 <refname>SD_NOTICE</refname>
54 <refname>SD_INFO</refname>
55 <refname>SD_DEBUG</refname>
57 new-style daemons</refpurpose>
62 <funcsynopsisinfo>#include <systemd/sd-daemon.h></funcsynopsisinfo>
66 <command>pkg-config --cflags --libs libsystemd</command>
72 <title>Description</title>
74 <para><filename>sd-daemon.h</filename> provide APIs
75 for new-style daemons, as implemented by the
76 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
80 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
81 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
82 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
83 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
84 <citerefentry><refentrytitle>sd_watchdog_enabled</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>
89 <programlisting>#define SD_EMERG "<0>" /* system is unusable */
90 #define SD_ALERT "<1>" /* action must be taken immediately */
91 #define SD_CRIT "<2>" /* critical conditions */
92 #define SD_ERR "<3>" /* error conditions */
93 #define SD_WARNING "<4>" /* warning conditions */
94 #define SD_NOTICE "<5>" /* normal but significant condition */
95 #define SD_INFO "<6>" /* informational */
96 #define SD_DEBUG "<7>" /* debug-level messages */</programlisting>
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
102 <varname>StandardError=journal</varname>,
103 <varname>StandardError=syslog</varname> or
104 <varname>StandardError=kmsg</varname>, these prefixes
105 can be used to encode a log level in lines
106 printed. This is similar to the kernel
107 <function>printk()</function>-style logging. See
108 <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
109 for more information.</para>
111 <para>The log levels are identical to
112 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
113 log level system. To use these prefixes simply prefix
114 every line with one of these strings. A line that is
115 not prefixed will be logged at the default log level
119 <title>Hello World</title>
121 <para>A daemon may log with the log level
122 NOTICE by issuing this call:</para>
124 <programlisting>fprintf(stderr, SD_NOTICE "Hello World!\n");</programlisting>
128 <xi:include href="libsystemd-pkgconfig.xml" />
131 <title>See Also</title>
133 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
134 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
137 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
138 <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
139 <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
140 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
141 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
142 <citerefentry project='man-pages'><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
143 <citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
144 <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>