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