<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"lib.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"lib.html" title='Python Library Reference'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"next" href=
"module-commands.html" />
<link rel=
"prev" href=
"module-nis.html" />
<link rel=
"parent" href=
"unix.html" />
<link rel=
"next" href=
"module-commands.html" />
<meta name='aesop' content='information'
/>
<title>8.16 syslog -- Unix syslog library routines
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"8.15 nis "
href=
"module-nis.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"8. Unix Specific Services"
href=
"unix.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"8.17 commands "
href=
"module-commands.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-nis.html">8.15 nis
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"unix.html">8. Unix Specific Services
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-commands.html">8.17 commands
</A>
<!--End of Navigation Panel-->
<H1><A NAME=
"SECTION00101600000000000000000">
8.16 <tt class=
"module">syslog
</tt> --
<span class=
"Unix">Unix
</span> syslog library routines
</A>
<A NAME=
"module-syslog"></A>
<p class=
"availability">Availability:
<span
class=
"platform">Unix
</span>.
</p>
This module provides an interface to the
<span class=
"Unix">Unix
</span> <code>syslog
</code> library
routines. Refer to the
<span class=
"Unix">Unix
</span> manual pages for a detailed description
of the
<code>syslog
</code> facility.
The module defines the following functions:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3082' xml:id='l2h-
3082'
class=
"function">syslog
</tt></b>(
</nobr></td>
<td><var></var><big>[
</big><var>priority,
</var><big>]
</big><var> message
</var>)
</td></tr></table></dt>
Send the string
<var>message
</var> to the system logger. A trailing
newline is added if necessary. Each message is tagged with a priority
composed of a
<var>facility
</var> and a
<var>level
</var>. The optional
<var>priority
</var> argument, which defaults to
<tt class=
"constant">LOG_INFO
</tt>,
determines the message priority. If the facility is not encoded in
<var>priority
</var> using logical-or (
<code>LOG_INFO | LOG_USER
</code>), the
value given in the
<tt class=
"function">openlog()
</tt> call is used.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3083' xml:id='l2h-
3083'
class=
"function">openlog
</tt></b>(
</nobr></td>
<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>
Logging options other than the defaults can be set by explicitly
opening the log file with
<tt class=
"function">openlog()
</tt> prior to calling
<tt class=
"function">syslog()
</tt>. The defaults are (usually)
<var>ident
</var> =
<code>'syslog'
</code>,
<var>logopt
</var> =
<code>0</code>,
<var>facility
</var> =
<tt class=
"constant">LOG_USER
</tt>. The
<var>ident
</var> argument is a string which is
prepended to every message. The optional
<var>logopt
</var> argument is a
bit field - see below for possible values to combine. The optional
<var>facility
</var> argument sets the default facility for messages which
do not have a facility explicitly encoded.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3084' xml:id='l2h-
3084'
class=
"function">closelog
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3085' xml:id='l2h-
3085'
class=
"function">setlogmask
</tt></b>(
</nobr></td>
<td><var>maskpri
</var>)
</td></tr></table></dt>
Set the priority mask to
<var>maskpri
</var> and return the
previous mask value. Calls to
<tt class=
"function">syslog()
</tt> with a priority
level not set in
<var>maskpri
</var> are ignored. The default is to log all
priorities. The function
<code>LOG_MASK(
<var>pri
</var>)
</code> calculates the
mask for the individual priority
<var>pri
</var>. The function
<code>LOG_UPTO(
<var>pri
</var>)
</code> calculates the mask for all priorities up
to and including
<var>pri
</var>.
The module defines the following constants:
<DT><STRONG>Priority levels (high to low):
</STRONG></DT>
<tt class=
"constant">LOG_EMERG
</tt>,
<tt class=
"constant">LOG_ALERT
</tt>,
<tt class=
"constant">LOG_CRIT
</tt>,
<tt class=
"constant">LOG_ERR
</tt>,
<tt class=
"constant">LOG_WARNING
</tt>,
<tt class=
"constant">LOG_NOTICE
</tt>,
<tt class=
"constant">LOG_INFO
</tt>,
<tt class=
"constant">LOG_DEBUG
</tt>.
<DT><STRONG>Facilities:
</STRONG></DT>
<tt class=
"constant">LOG_KERN
</tt>,
<tt class=
"constant">LOG_USER
</tt>,
<tt class=
"constant">LOG_MAIL
</tt>,
<tt class=
"constant">LOG_DAEMON
</tt>,
<tt class=
"constant">LOG_AUTH
</tt>,
<tt class=
"constant">LOG_LPR
</tt>,
<tt class=
"constant">LOG_NEWS
</tt>,
<tt class=
"constant">LOG_UUCP
</tt>,
<tt class=
"constant">LOG_CRON
</tt> and
<tt class=
"constant">LOG_LOCAL0
</tt> to
<tt class=
"constant">LOG_LOCAL7
</tt>.
<DT><STRONG>Log options:
</STRONG></DT>
<tt class=
"constant">LOG_PID
</tt>,
<tt class=
"constant">LOG_CONS
</tt>,
<tt class=
"constant">LOG_NDELAY
</tt>,
<tt class=
"constant">LOG_NOWAIT
</tt> and
<tt class=
"constant">LOG_PERROR
</tt> if defined in
<code><syslog.h
></code>.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"8.15 nis "
href=
"module-nis.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"8. Unix Specific Services"
href=
"unix.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"8.17 commands "
href=
"module-commands.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-nis.html">8.15 nis
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"unix.html">8. Unix Specific Services
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-commands.html">8.17 commands
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.