| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-commands.html" /> |
| 13 | <link rel="prev" href="module-nis.html" /> |
| 14 | <link rel="parent" href="unix.html" /> |
| 15 | <link rel="next" href="module-commands.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>8.16 syslog -- Unix syslog library routines</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="8.15 nis " |
| 25 | href="module-nis.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="8. Unix Specific Services" |
| 28 | href="unix.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="8.17 commands " |
| 31 | href="module-commands.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-nis.html">8.15 nis </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="unix.html">8. Unix Specific Services</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="module-commands.html">8.17 commands </A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION00101600000000000000000"> |
| 56 | 8.16 <tt class="module">syslog</tt> -- |
| 57 | <span class="Unix">Unix</span> syslog library routines</A> |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | <A NAME="module-syslog"></A> |
| 62 | <p class="availability">Availability: <span |
| 63 | class="platform">Unix</span>.</p> |
| 64 | |
| 65 | <P> |
| 66 | This module provides an interface to the <span class="Unix">Unix</span> <code>syslog</code> library |
| 67 | routines. Refer to the <span class="Unix">Unix</span> manual pages for a detailed description |
| 68 | of the <code>syslog</code> facility. |
| 69 | |
| 70 | <P> |
| 71 | The module defines the following functions: |
| 72 | |
| 73 | <P> |
| 74 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 75 | <td><nobr><b><tt id='l2h-3082' xml:id='l2h-3082' class="function">syslog</tt></b>(</nobr></td> |
| 76 | <td><var></var><big>[</big><var>priority,</var><big>]</big><var> message</var>)</td></tr></table></dt> |
| 77 | <dd> |
| 78 | Send the string <var>message</var> to the system logger. A trailing |
| 79 | newline is added if necessary. Each message is tagged with a priority |
| 80 | composed of a <var>facility</var> and a <var>level</var>. The optional |
| 81 | <var>priority</var> argument, which defaults to <tt class="constant">LOG_INFO</tt>, |
| 82 | determines the message priority. If the facility is not encoded in |
| 83 | <var>priority</var> using logical-or (<code>LOG_INFO | LOG_USER</code>), the |
| 84 | value given in the <tt class="function">openlog()</tt> call is used. |
| 85 | </dl> |
| 86 | |
| 87 | <P> |
| 88 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 89 | <td><nobr><b><tt id='l2h-3083' xml:id='l2h-3083' class="function">openlog</tt></b>(</nobr></td> |
| 90 | <td><var>ident</var><big>[</big><var>, logopt</var><big>[</big><var>, facility</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 91 | <dd> |
| 92 | Logging options other than the defaults can be set by explicitly |
| 93 | opening the log file with <tt class="function">openlog()</tt> prior to calling |
| 94 | <tt class="function">syslog()</tt>. The defaults are (usually) <var>ident</var> = |
| 95 | <code>'syslog'</code>, <var>logopt</var> = <code>0</code>, <var>facility</var> = |
| 96 | <tt class="constant">LOG_USER</tt>. The <var>ident</var> argument is a string which is |
| 97 | prepended to every message. The optional <var>logopt</var> argument is a |
| 98 | bit field - see below for possible values to combine. The optional |
| 99 | <var>facility</var> argument sets the default facility for messages which |
| 100 | do not have a facility explicitly encoded. |
| 101 | </dl> |
| 102 | |
| 103 | <P> |
| 104 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 105 | <td><nobr><b><tt id='l2h-3084' xml:id='l2h-3084' class="function">closelog</tt></b>(</nobr></td> |
| 106 | <td><var></var>)</td></tr></table></dt> |
| 107 | <dd> |
| 108 | Close the log file. |
| 109 | </dl> |
| 110 | |
| 111 | <P> |
| 112 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 113 | <td><nobr><b><tt id='l2h-3085' xml:id='l2h-3085' class="function">setlogmask</tt></b>(</nobr></td> |
| 114 | <td><var>maskpri</var>)</td></tr></table></dt> |
| 115 | <dd> |
| 116 | Set the priority mask to <var>maskpri</var> and return the |
| 117 | previous mask value. Calls to <tt class="function">syslog()</tt> with a priority |
| 118 | level not set in <var>maskpri</var> are ignored. The default is to log all |
| 119 | priorities. The function <code>LOG_MASK(<var>pri</var>)</code> calculates the |
| 120 | mask for the individual priority <var>pri</var>. The function |
| 121 | <code>LOG_UPTO(<var>pri</var>)</code> calculates the mask for all priorities up |
| 122 | to and including <var>pri</var>. |
| 123 | </dl> |
| 124 | |
| 125 | <P> |
| 126 | The module defines the following constants: |
| 127 | |
| 128 | <P> |
| 129 | <DL> |
| 130 | <DT><STRONG>Priority levels (high to low):</STRONG></DT> |
| 131 | <DD><P> |
| 132 | <tt class="constant">LOG_EMERG</tt>, <tt class="constant">LOG_ALERT</tt>, <tt class="constant">LOG_CRIT</tt>, |
| 133 | <tt class="constant">LOG_ERR</tt>, <tt class="constant">LOG_WARNING</tt>, <tt class="constant">LOG_NOTICE</tt>, |
| 134 | <tt class="constant">LOG_INFO</tt>, <tt class="constant">LOG_DEBUG</tt>. |
| 135 | |
| 136 | <P> |
| 137 | </DD> |
| 138 | <DT><STRONG>Facilities:</STRONG></DT> |
| 139 | <DD><P> |
| 140 | <tt class="constant">LOG_KERN</tt>, <tt class="constant">LOG_USER</tt>, <tt class="constant">LOG_MAIL</tt>, |
| 141 | <tt class="constant">LOG_DAEMON</tt>, <tt class="constant">LOG_AUTH</tt>, <tt class="constant">LOG_LPR</tt>, |
| 142 | <tt class="constant">LOG_NEWS</tt>, <tt class="constant">LOG_UUCP</tt>, <tt class="constant">LOG_CRON</tt> and |
| 143 | <tt class="constant">LOG_LOCAL0</tt> to <tt class="constant">LOG_LOCAL7</tt>. |
| 144 | |
| 145 | <P> |
| 146 | </DD> |
| 147 | <DT><STRONG>Log options:</STRONG></DT> |
| 148 | <DD><P> |
| 149 | <tt class="constant">LOG_PID</tt>, <tt class="constant">LOG_CONS</tt>, <tt class="constant">LOG_NDELAY</tt>, |
| 150 | <tt class="constant">LOG_NOWAIT</tt> and <tt class="constant">LOG_PERROR</tt> if defined in |
| 151 | <code><syslog.h></code>. |
| 152 | |
| 153 | <P> |
| 154 | </DD> |
| 155 | </DL> |
| 156 | |
| 157 | <DIV CLASS="navigation"> |
| 158 | <div class='online-navigation'> |
| 159 | <p></p><hr /> |
| 160 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 161 | <tr> |
| 162 | <td class='online-navigation'><a rel="prev" title="8.15 nis " |
| 163 | href="module-nis.html"><img src='../icons/previous.png' |
| 164 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 165 | <td class='online-navigation'><a rel="parent" title="8. Unix Specific Services" |
| 166 | href="unix.html"><img src='../icons/up.png' |
| 167 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 168 | <td class='online-navigation'><a rel="next" title="8.17 commands " |
| 169 | href="module-commands.html"><img src='../icons/next.png' |
| 170 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 171 | <td align="center" width="100%">Python Library Reference</td> |
| 172 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 173 | href="contents.html"><img src='../icons/contents.png' |
| 174 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 175 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 176 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 177 | <td class='online-navigation'><a rel="index" title="Index" |
| 178 | href="genindex.html"><img src='../icons/index.png' |
| 179 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 180 | </tr></table> |
| 181 | <div class='online-navigation'> |
| 182 | <b class="navlabel">Previous:</b> |
| 183 | <a class="sectref" rel="prev" href="module-nis.html">8.15 nis </A> |
| 184 | <b class="navlabel">Up:</b> |
| 185 | <a class="sectref" rel="parent" href="unix.html">8. Unix Specific Services</A> |
| 186 | <b class="navlabel">Next:</b> |
| 187 | <a class="sectref" rel="next" href="module-commands.html">8.17 commands </A> |
| 188 | </div> |
| 189 | </div> |
| 190 | <hr /> |
| 191 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 192 | </DIV> |
| 193 | <!--End of Navigation Panel--> |
| 194 | <ADDRESS> |
| 195 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 196 | </ADDRESS> |
| 197 | </BODY> |
| 198 | </HTML> |