Debian Codegraph @

upstream/debian-trixie/man3/sd-daemon.3

raw
1 '\" t
2 .TH "SD\-DAEMON" "3" "" "systemd 257.13" "sd-daemon"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd-daemon, SD_EMERG, SD_ALERT, SD_CRIT, SD_ERR, SD_WARNING, SD_NOTICE, SD_INFO, SD_DEBUG \- APIs for new\-style daemons
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-daemon\&.h>
29 .fi
30 .ft
31 .HP \w'\fBpkg\-config\ \-\-cflags\ \-\-libs\ libsystemd\fR\ 'u
32 \fBpkg\-config \-\-cflags \-\-libs libsystemd\fR
33 .SH "DESCRIPTION"
34 .PP
35 sd\-daemon\&.h
36 is part of
37 \fBlibsystemd\fR(3)
38 and provides APIs for new\-style daemons, as implemented by the
39 \fBsystemd\fR(1)
40 service manager\&.
41 .PP
42 See
43 \fBsd_listen_fds\fR(3),
44 \fBsd_notify\fR(3),
45 \fBsd_booted\fR(3),
46 \fBsd_is_fifo\fR(3),
47 \fBsd_watchdog_enabled\fR(3)
48 for more information about the functions implemented\&. In addition to these functions, a couple of logging prefixes are defined as macros:
49 .sp
50 .if n \{\
51 .RS 4
52 .\}
53 .nf
54 #define SD_EMERG "<0>" /* system is unusable */
55 #define SD_ALERT "<1>" /* action must be taken immediately */
56 #define SD_CRIT "<2>" /* critical conditions */
57 #define SD_ERR "<3>" /* error conditions */
58 #define SD_WARNING "<4>" /* warning conditions */
59 #define SD_NOTICE "<5>" /* normal but significant condition */
60 #define SD_INFO "<6>" /* informational */
61 #define SD_DEBUG "<7>" /* debug\-level messages */
62 .fi
63 .if n \{\
64 .RE
65 .\}
66 .PP
67 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
68 \fIStandardError=journal\fR
69 or
70 \fIStandardError=kmsg\fR
71 (and similar with
72 \fIStandardOutput=\fR), these prefixes can be used to encode a log level in lines printed\&. This is similar to the kernel
73 \fBprintk()\fR\-style logging\&. See
74 \fBklogctl\fR(2)
75 for more information\&.
76 .PP
77 The log levels are identical to
78 \fBsyslog\fR(3)\*(Aqs 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\&.
79 .PP
80 \fBExample\ \&1.\ \&Hello World\fR
81 .PP
82 A daemon may log with the log level NOTICE by issuing this call:
83 .sp
84 .if n \{\
85 .RS 4
86 .\}
87 .nf
88 fprintf(stderr, SD_NOTICE "Hello World!\en");
89 .fi
90 .if n \{\
91 .RE
92 .\}
93 .SH "NOTES"
94 .PP
95 Functions described here are available as a shared library, which can be compiled against and linked to with the
96 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
97 file\&.
98 .PP
99 The code described here uses
100 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
101 \fBsetenv\fR(3)
102 from a parallel thread\&. It is recommended to only do calls to
103 \fBsetenv()\fR
104 from an early phase of the program when no other threads have been started\&.
105 .SH "SEE ALSO"
106 .PP
107 \fBsystemd\fR(1), \fBsd_listen_fds\fR(3), \fBsd_notify\fR(3), \fBsd_booted\fR(3), \fBsd_is_fifo\fR(3), \fBsd_watchdog_enabled\fR(3), \fBdaemon\fR(7), \fBsystemd.service\fR(5), \fBsystemd.socket\fR(5), \fBfprintf\fR(3), \fBpkg-config\fR(1)