logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

closelog.3p (7870B)


  1. '\" et
  2. .TH CLOSELOG "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. closelog,
  12. openlog,
  13. setlogmask,
  14. syslog
  15. \(em control system log
  16. .SH SYNOPSIS
  17. .LP
  18. .nf
  19. #include <syslog.h>
  20. .P
  21. void closelog(void);
  22. void openlog(const char *\fIident\fP, int \fIlogopt\fP, int \fIfacility\fP);
  23. int setlogmask(int \fImaskpri\fP);
  24. void syslog(int \fIpriority\fP, const char *\fImessage\fP, ... /* \fIarguments\fP */);
  25. .fi
  26. .SH DESCRIPTION
  27. The
  28. \fIsyslog\fR()
  29. function shall send a message to an implementation-defined logging
  30. facility, which may log it in an implementation-defined system log,
  31. write it to the system console, forward it to a list of users, or
  32. forward it to the logging facility on another host over the network.
  33. The logged message shall include a message header and a message body.
  34. The message header contains at least a timestamp and a tag string.
  35. .P
  36. The message body is generated from the
  37. .IR message
  38. and following arguments in the same manner as if these were arguments
  39. to
  40. \fIprintf\fR(),
  41. except that the additional conversion specification
  42. .BR %m
  43. shall be recognized; it shall convert no arguments, shall cause the
  44. output of the error message string associated with the value of
  45. .IR errno
  46. on entry to
  47. \fIsyslog\fR(),
  48. and may be mixed with argument specifications of the \fR"%\fIn\fR$"\fR
  49. form. If a complete conversion specification with the
  50. .BR m
  51. conversion specifier character is not just
  52. .BR %m ,
  53. the behavior is undefined. A trailing
  54. <newline>
  55. may be added if needed.
  56. .P
  57. Values of the
  58. .IR priority
  59. argument are formed by OR'ing together a severity-level value and an
  60. optional facility value. If no facility value is specified, the current
  61. default facility value is used.
  62. .P
  63. Possible values of severity level include:
  64. .IP LOG_EMERG 12
  65. A panic condition.
  66. .IP LOG_ALERT 12
  67. A condition that should be corrected immediately, such as a corrupted
  68. system database.
  69. .IP LOG_CRIT 12
  70. Critical conditions, such as hard device errors.
  71. .IP LOG_ERR 12
  72. Errors.
  73. .IP LOG_WARNING 12
  74. .br
  75. Warning messages.
  76. .IP LOG_NOTICE 12
  77. Conditions that are not error conditions, but that may require special
  78. handling.
  79. .IP LOG_INFO 12
  80. Informational messages.
  81. .IP LOG_DEBUG 12
  82. Messages that contain information normally of use only when debugging a
  83. program.
  84. .P
  85. The facility indicates the application or system component generating
  86. the message. Possible facility values include:
  87. .IP LOG_USER 12
  88. Messages generated by arbitrary processes. This is the default facility
  89. identifier if none is specified.
  90. .IP LOG_LOCAL0 12
  91. Reserved for local use.
  92. .IP LOG_LOCAL1 12
  93. Reserved for local use.
  94. .IP LOG_LOCAL2 12
  95. Reserved for local use.
  96. .IP LOG_LOCAL3 12
  97. Reserved for local use.
  98. .IP LOG_LOCAL4 12
  99. Reserved for local use.
  100. .IP LOG_LOCAL5 12
  101. Reserved for local use.
  102. .IP LOG_LOCAL6 12
  103. Reserved for local use.
  104. .IP LOG_LOCAL7 12
  105. Reserved for local use.
  106. .P
  107. The
  108. \fIopenlog\fR()
  109. function shall set process attributes that affect subsequent calls to
  110. \fIsyslog\fR().
  111. The
  112. .IR ident
  113. argument is a string that is prepended to every message. The
  114. .IR logopt
  115. argument indicates logging options. Values for
  116. .IR logopt
  117. are constructed by a bitwise-inclusive OR of zero or more of the
  118. following:
  119. .IP LOG_PID 12
  120. Log the process ID with each message. This is useful for identifying
  121. specific processes.
  122. .IP LOG_CONS 12
  123. Write messages to the system console if they cannot be sent to the
  124. logging facility. The
  125. \fIsyslog\fR()
  126. function ensures that the process does not acquire the console as a
  127. controlling terminal in the process of writing the message.
  128. .IP LOG_NDELAY 12
  129. Open the connection to the logging facility immediately. Normally the
  130. open is delayed until the first message is logged. This is useful for
  131. programs that need to manage the order in which file descriptors are
  132. allocated.
  133. .IP LOG_ODELAY 12
  134. Delay open until
  135. \fIsyslog\fR()
  136. is called.
  137. .IP LOG_NOWAIT 12
  138. Do not wait for child processes that may have been created during the
  139. course of logging the message. This option should be used by processes
  140. that enable notification of child termination using SIGCHLD, since
  141. \fIsyslog\fR()
  142. may otherwise block waiting for a child whose exit status has already
  143. been collected.
  144. .P
  145. The
  146. .IR facility
  147. argument encodes a default facility to be assigned to all messages that
  148. do not have an explicit facility already encoded. The initial default
  149. facility is LOG_USER.
  150. .P
  151. The
  152. \fIopenlog\fR()
  153. and
  154. \fIsyslog\fR()
  155. functions may allocate a file descriptor. It is not necessary to call
  156. \fIopenlog\fR()
  157. prior to calling
  158. \fIsyslog\fR().
  159. .P
  160. The
  161. \fIcloselog\fR()
  162. function shall close any open file descriptors allocated by previous
  163. calls to
  164. \fIopenlog\fR()
  165. or
  166. \fIsyslog\fR().
  167. .P
  168. The
  169. \fIsetlogmask\fR()
  170. function shall set the log priority mask for the current process to
  171. .IR maskpri
  172. and return the previous mask. If the
  173. .IR maskpri
  174. argument is 0, the current log mask is not modified. Calls by the
  175. current process to
  176. \fIsyslog\fR()
  177. with a priority not set in
  178. .IR maskpri
  179. shall be rejected. The default log mask allows all priorities to be
  180. logged. A call to
  181. \fIopenlog\fR()
  182. is not required prior to calling
  183. \fIsetlogmask\fR().
  184. .P
  185. Symbolic constants for use as values of the
  186. .IR logopt ,
  187. .IR facility ,
  188. .IR priority ,
  189. and
  190. .IR maskpri
  191. arguments are defined in the
  192. .IR <syslog.h>
  193. header.
  194. .SH "RETURN VALUE"
  195. The
  196. \fIsetlogmask\fR()
  197. function shall return the previous log priority mask. The
  198. \fIcloselog\fR(),
  199. \fIopenlog\fR(),
  200. and
  201. \fIsyslog\fR()
  202. functions shall not return a value.
  203. .SH ERRORS
  204. No errors are defined.
  205. .LP
  206. .IR "The following sections are informative."
  207. .SH EXAMPLES
  208. .SS "Using openlog(\|)"
  209. .P
  210. The following example causes subsequent calls to
  211. \fIsyslog\fR()
  212. to log the process ID with each message, and to write messages to the
  213. system console if they cannot be sent to the logging facility.
  214. .sp
  215. .RS 4
  216. .nf
  217. #include <syslog.h>
  218. .P
  219. char *ident = "Process demo";
  220. int logopt = LOG_PID | LOG_CONS;
  221. int facility = LOG_USER;
  222. \&...
  223. openlog(ident, logopt, facility);
  224. .fi
  225. .P
  226. .RE
  227. .SS "Using setlogmask(\|)"
  228. .P
  229. The following example causes subsequent calls to
  230. \fIsyslog\fR()
  231. to accept error messages, and to reject all other messages.
  232. .sp
  233. .RS 4
  234. .nf
  235. #include <syslog.h>
  236. .P
  237. int result;
  238. int mask = LOG_MASK (LOG_ERR);
  239. \&...
  240. result = setlogmask(mask);
  241. .fi
  242. .P
  243. .RE
  244. .SS "Using syslog"
  245. .P
  246. The following example sends the message
  247. .BR \(dqThis is a message\(dq
  248. to the default logging facility, marking the message as an error
  249. message generated by random processes.
  250. .sp
  251. .RS 4
  252. .nf
  253. #include <syslog.h>
  254. .P
  255. char *message = "This is a message";
  256. int priority = LOG_ERR | LOG_USER;
  257. \&...
  258. syslog(priority, message);
  259. .fi
  260. .P
  261. .RE
  262. .SH "APPLICATION USAGE"
  263. None.
  264. .SH RATIONALE
  265. None.
  266. .SH "FUTURE DIRECTIONS"
  267. None.
  268. .SH "SEE ALSO"
  269. .IR "\fIfprintf\fR\^(\|)"
  270. .P
  271. The Base Definitions volume of POSIX.1\(hy2017,
  272. .IR "\fB<syslog.h>\fP"
  273. .\"
  274. .SH COPYRIGHT
  275. Portions of this text are reprinted and reproduced in electronic form
  276. from IEEE Std 1003.1-2017, Standard for Information Technology
  277. -- Portable Operating System Interface (POSIX), The Open Group Base
  278. Specifications Issue 7, 2018 Edition,
  279. Copyright (C) 2018 by the Institute of
  280. Electrical and Electronics Engineers, Inc and The Open Group.
  281. In the event of any discrepancy between this version and the original IEEE and
  282. The Open Group Standard, the original IEEE and The Open Group Standard
  283. is the referee document. The original Standard can be obtained online at
  284. http://www.opengroup.org/unix/online.html .
  285. .PP
  286. Any typographical or formatting errors that appear
  287. in this page are most likely
  288. to have been introduced during the conversion of the source files to
  289. man page format. To report such errors, see
  290. https://www.kernel.org/doc/man-pages/reporting_bugs.html .