| 1 |
'\" t |
| 2 |
.TH "SD\-DAEMON" "3" "" "systemd 261~rc3" "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), and |
| 48 |
\fBsd_pidfd_get_inode_id\fR(3) |
| 49 |
for more information about the functions implemented\&. In addition to these functions, a couple of logging prefixes are defined as macros: |
| 50 |
.sp |
| 51 |
.if n \{\ |
| 52 |
.RS 4 |
| 53 |
.\} |
| 54 |
.nf |
| 55 |
#define SD_EMERG "<0>" /* system is unusable */ |
| 56 |
#define SD_ALERT "<1>" /* action must be taken immediately */ |
| 57 |
#define SD_CRIT "<2>" /* critical conditions */ |
| 58 |
#define SD_ERR "<3>" /* error conditions */ |
| 59 |
#define SD_WARNING "<4>" /* warning conditions */ |
| 60 |
#define SD_NOTICE "<5>" /* normal but significant condition */ |
| 61 |
#define SD_INFO "<6>" /* informational */ |
| 62 |
#define SD_DEBUG "<7>" /* debug\-level messages */ |
| 63 |
.fi |
| 64 |
.if n \{\ |
| 65 |
.RE |
| 66 |
.\} |
| 67 |
.PP |
| 68 |
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 |
| 69 |
\fIStandardError=journal\fR |
| 70 |
or |
| 71 |
\fIStandardError=kmsg\fR |
| 72 |
(and similar with |
| 73 |
\fIStandardOutput=\fR), these prefixes can be used to encode a log level in lines printed\&. This is similar to the kernel |
| 74 |
\fBprintk()\fR\-style logging\&. See |
| 75 |
\fBklogctl\fR(2) |
| 76 |
for more information\&. |
| 77 |
.PP |
| 78 |
The log levels are identical to |
| 79 |
\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\&. |
| 80 |
.PP |
| 81 |
\fBExample\ \&1.\ \&Hello World\fR |
| 82 |
.PP |
| 83 |
A daemon may log with the log level NOTICE by issuing this call: |
| 84 |
.sp |
| 85 |
.if n \{\ |
| 86 |
.RS 4 |
| 87 |
.\} |
| 88 |
.nf |
| 89 |
fprintf(stderr, SD_NOTICE "Hello World!\en"); |
| 90 |
.fi |
| 91 |
.if n \{\ |
| 92 |
.RE |
| 93 |
.\} |
| 94 |
.SH "NOTES" |
| 95 |
.PP |
| 96 |
Functions described here are available as a shared library, which can be compiled against and linked to with the |
| 97 |
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1) |
| 98 |
file\&. |
| 99 |
.PP |
| 100 |
The code described here uses |
| 101 |
\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 |
| 102 |
\fBsetenv\fR(3) |
| 103 |
from a parallel thread\&. It is recommended to only do calls to |
| 104 |
\fBsetenv()\fR |
| 105 |
from an early phase of the program when no other threads have been started\&. |
| 106 |
.SH "SEE ALSO" |
| 107 |
.PP |
| 108 |
\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), \fBsd_pidfd_get_inode_id\fR(3), \fBdaemon\fR(7), \fBsystemd.service\fR(5), \fBsystemd.socket\fR(5), \fBfprintf\fR(3), \fBpkg-config\fR(1) |