add directory study
This commit is contained in:
302
study/Ref-docs/POSIX/susv3/functions/closelog.html
Normal file
302
study/Ref-docs/POSIX/susv3/functions/closelog.html
Normal file
@@ -0,0 +1,302 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
||||
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
||||
<title>closelog</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
||||
</script>
|
||||
|
||||
<basefont size="3"> <a name="closelog"></a> <a name="tag_03_82"></a><!-- closelog -->
|
||||
<!--header start-->
|
||||
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
||||
IEEE Std 1003.1-2001<br>
|
||||
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
||||
|
||||
<!--header end-->
|
||||
<hr size="2" noshade>
|
||||
<h4><a name="tag_03_82_01"></a>NAME</h4>
|
||||
|
||||
<blockquote>closelog, openlog, setlogmask, syslog - control system log</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_02"></a>SYNOPSIS</h4>
|
||||
|
||||
<blockquote class="synopsis">
|
||||
<div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
||||
"[Option Start]" border="0"> #include <<a href="../basedefs/syslog.h.html">syslog.h</a>><br>
|
||||
<br>
|
||||
void closelog(void);<br>
|
||||
void openlog(const char *</tt><i>ident</i><tt>, int</tt> <i>logopt</i><tt>, int</tt> <i>facility</i><tt>);<br>
|
||||
int setlogmask(int</tt> <i>maskpri</i><tt>);<br>
|
||||
void syslog(int</tt> <i>priority</i><tt>, const char *</tt><i>message</i><tt>, ... /*</tt> <i>arguments</i> <tt>*/); <img src=
|
||||
"../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
||||
|
||||
<tt><br>
|
||||
</tt></blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_03"></a>DESCRIPTION</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>syslog</i>() function shall send a message to an implementation-defined logging facility, which may log it in an
|
||||
implementation-defined system log, write it to the system console, forward it to a list of users, or forward it to the logging
|
||||
facility on another host over the network. The logged message shall include a message header and a message body. The message header
|
||||
contains at least a timestamp and a tag string.</p>
|
||||
|
||||
<p>The message body is generated from the <i>message</i> and following arguments in the same manner as if these were arguments to
|
||||
<a href="../functions/printf.html"><i>printf</i>()</a>, except that the additional conversion specification <tt>%m</tt> shall be
|
||||
recognized; it shall convert no arguments, shall cause the output of the error message string associated with the value of
|
||||
<i>errno</i> on entry to <i>syslog</i>(), and may be mixed with argument specifications of the <tt>"%</tt><i>n</i><tt>$"</tt> form.
|
||||
If a complete conversion specification with the <tt>m</tt> conversion specifier character is not just <tt>%m</tt> , the behavior is
|
||||
undefined. A trailing <newline> may be added if needed.</p>
|
||||
|
||||
<p>Values of the <i>priority</i> argument are formed by OR'ing together a severity-level value and an optional facility value. If
|
||||
no facility value is specified, the current default facility value is used.</p>
|
||||
|
||||
<p>Possible values of severity level include:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt>LOG_EMERG</dt>
|
||||
|
||||
<dd>A panic condition.</dd>
|
||||
|
||||
<dt>LOG_ALERT</dt>
|
||||
|
||||
<dd>A condition that should be corrected immediately, such as a corrupted system database.</dd>
|
||||
|
||||
<dt>LOG_CRIT</dt>
|
||||
|
||||
<dd>Critical conditions, such as hard device errors.</dd>
|
||||
|
||||
<dt>LOG_ERR</dt>
|
||||
|
||||
<dd>Errors.</dd>
|
||||
|
||||
<dt>LOG_WARNING</dt>
|
||||
|
||||
<dd><br>
|
||||
Warning messages.</dd>
|
||||
|
||||
<dt>LOG_NOTICE</dt>
|
||||
|
||||
<dd>Conditions that are not error conditions, but that may require special handling.</dd>
|
||||
|
||||
<dt>LOG_INFO</dt>
|
||||
|
||||
<dd>Informational messages.</dd>
|
||||
|
||||
<dt>LOG_DEBUG</dt>
|
||||
|
||||
<dd>Messages that contain information normally of use only when debugging a program.</dd>
|
||||
</dl>
|
||||
|
||||
<p>The facility indicates the application or system component generating the message. Possible facility values include:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt>LOG_USER</dt>
|
||||
|
||||
<dd>Messages generated by arbitrary processes. This is the default facility identifier if none is specified.</dd>
|
||||
|
||||
<dt>LOG_LOCAL0</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
|
||||
<dt>LOG_LOCAL1</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
|
||||
<dt>LOG_LOCAL2</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
|
||||
<dt>LOG_LOCAL3</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
|
||||
<dt>LOG_LOCAL4</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
|
||||
<dt>LOG_LOCAL5</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
|
||||
<dt>LOG_LOCAL6</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
|
||||
<dt>LOG_LOCAL7</dt>
|
||||
|
||||
<dd>Reserved for local use.</dd>
|
||||
</dl>
|
||||
|
||||
<p>The <i>openlog</i>() function shall set process attributes that affect subsequent calls to <i>syslog</i>(). The <i>ident</i>
|
||||
argument is a string that is prepended to every message. The <i>logopt</i> argument indicates logging options. Values for
|
||||
<i>logopt</i> are constructed by a bitwise-inclusive OR of zero or more of the following:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt>LOG_PID</dt>
|
||||
|
||||
<dd>Log the process ID with each message. This is useful for identifying specific processes.</dd>
|
||||
|
||||
<dt>LOG_CONS</dt>
|
||||
|
||||
<dd>Write messages to the system console if they cannot be sent to the logging facility. The <i>syslog</i>() function ensures that
|
||||
the process does not acquire the console as a controlling terminal in the process of writing the message.</dd>
|
||||
|
||||
<dt>LOG_NDELAY</dt>
|
||||
|
||||
<dd>Open the connection to the logging facility immediately. Normally the open is delayed until the first message is logged. This
|
||||
is useful for programs that need to manage the order in which file descriptors are allocated.</dd>
|
||||
|
||||
<dt>LOG_ODELAY</dt>
|
||||
|
||||
<dd>Delay open until <i>syslog</i>() is called.</dd>
|
||||
|
||||
<dt>LOG_NOWAIT</dt>
|
||||
|
||||
<dd>Do not wait for child processes that may have been created during the course of logging the message. This option should be used
|
||||
by processes that enable notification of child termination using SIGCHLD, since <i>syslog</i>() may otherwise block waiting for a
|
||||
child whose exit status has already been collected.</dd>
|
||||
</dl>
|
||||
|
||||
<p>The <i>facility</i> argument encodes a default facility to be assigned to all messages that do not have an explicit facility
|
||||
already encoded. The initial default facility is LOG_USER.</p>
|
||||
|
||||
<p>The <i>openlog</i>() and <i>syslog</i>() functions may allocate a file descriptor. It is not necessary to call <i>openlog</i>()
|
||||
prior to calling <i>syslog</i>().</p>
|
||||
|
||||
<p>The <i>closelog</i>() function shall close any open file descriptors allocated by previous calls to <i>openlog</i>() or
|
||||
<i>syslog</i>().</p>
|
||||
|
||||
<p>The <i>setlogmask</i>() function shall set the log priority mask for the current process to <i>maskpri</i> and return the
|
||||
previous mask. If the <i>maskpri</i> argument is 0, the current log mask is not modified. Calls by the current process to
|
||||
<i>syslog</i>() with a priority not set in <i>maskpri</i> shall be rejected. The default log mask allows all priorities to be
|
||||
logged. A call to <i>openlog</i>() is not required prior to calling <i>setlogmask</i>().</p>
|
||||
|
||||
<p>Symbolic constants for use as values of the <i>logopt</i>, <i>facility</i>, <i>priority</i>, and <i>maskpri</i> arguments are
|
||||
defined in the <a href="../basedefs/syslog.h.html"><i><syslog.h></i></a> header.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_04"></a>RETURN VALUE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>setlogmask</i>() function shall return the previous log priority mask. The <i>closelog</i>(), <i>openlog</i>(), and
|
||||
<i>syslog</i>() functions shall not return a value.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_05"></a>ERRORS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>No errors are defined.</p>
|
||||
</blockquote>
|
||||
|
||||
<hr>
|
||||
<div class="box"><em>The following sections are informative.</em></div>
|
||||
|
||||
<h4><a name="tag_03_82_06"></a>EXAMPLES</h4>
|
||||
|
||||
<blockquote>
|
||||
<h5><a name="tag_03_82_06_01"></a>Using openlog()</h5>
|
||||
|
||||
<p>The following example causes subsequent calls to <i>syslog</i>() to log the process ID with each message, and to write messages
|
||||
to the system console if they cannot be sent to the logging facility.</p>
|
||||
|
||||
<pre>
|
||||
<tt>#include <syslog.h>
|
||||
<br>
|
||||
char *ident = "Process demo";
|
||||
int logopt = LOG_PID | LOG_CONS;
|
||||
int facility = LOG_USER;
|
||||
...
|
||||
openlog(ident, logopt, facility);
|
||||
</tt>
|
||||
</pre>
|
||||
|
||||
<h5><a name="tag_03_82_06_02"></a>Using setlogmask()</h5>
|
||||
|
||||
<p>The following example causes subsequent calls to <i>syslog</i>() to accept error messages or messages generated by arbitrary
|
||||
processes, and to reject all other messages.</p>
|
||||
|
||||
<pre>
|
||||
<tt>#include <syslog.h>
|
||||
<br>
|
||||
int result;
|
||||
int mask = LOG_MASK (LOG_ERR | LOG_USER);
|
||||
...
|
||||
result = setlogmask(mask);
|
||||
</tt>
|
||||
</pre>
|
||||
|
||||
<h5><a name="tag_03_82_06_03"></a>Using syslog</h5>
|
||||
|
||||
<p>The following example sends the message <tt>"This is a message"</tt> to the default logging facility, marking the message as an
|
||||
error message generated by random processes.</p>
|
||||
|
||||
<pre>
|
||||
<tt>#include <syslog.h>
|
||||
<br>
|
||||
char *message = "This is a message";
|
||||
int priority = LOG_ERR | LOG_USER;
|
||||
...
|
||||
syslog(priority, message);
|
||||
</tt>
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_07"></a>APPLICATION USAGE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_08"></a>RATIONALE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_09"></a>FUTURE DIRECTIONS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_10"></a>SEE ALSO</h4>
|
||||
|
||||
<blockquote>
|
||||
<p><a href="printf.html"><i>printf</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
||||
"../basedefs/syslog.h.html"><i><syslog.h></i></a></p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_11"></a>CHANGE HISTORY</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>First released in Issue 4, Version 2.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_82_12"></a>Issue 5</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>Moved from X/OPEN UNIX extension to BASE.</p>
|
||||
</blockquote>
|
||||
|
||||
<div class="box"><em>End of informative text.</em></div>
|
||||
|
||||
<hr>
|
||||
<hr size="2" noshade>
|
||||
<center><font size="2"><!--footer start-->
|
||||
UNIX ® is a registered Trademark of The Open Group.<br>
|
||||
POSIX ® is a registered Trademark of The IEEE.<br>
|
||||
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
||||
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
||||
]</font></center>
|
||||
|
||||
<!--footer end-->
|
||||
<hr size="2" noshade>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user