root / pykota / trunk / pykota / loggers / system.py @ 710

Revision 710, 1.2 kB (checked in by jalet, 21 years ago)

Forgotten default argument

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# PyKota
2#
3# PyKota : Print Quotas for CUPS
4#
5# (c) 2003 Jerome Alet <alet@librelogiciel.com>
6# You're welcome to redistribute this software under the
7# terms of the GNU General Public Licence version 2.0
8# or, at your option, any higher version.
9#
10# You can read the complete GNU GPL in the file COPYING
11# which should come along with this software, or visit
12# the Free Software Foundation's WEB site http://www.fsf.org
13#
14# $Id$
15#
16# $Log$
17# Revision 1.2  2003/02/05 23:47:54  jalet
18# Forgotten default argument
19#
20# Revision 1.1  2003/02/05 23:09:20  jalet
21# Name conflict
22#
23#
24#
25
26import sys
27import syslog
28
29class Logger :
30    """A logger class which logs to syslog."""
31    def __init__(self) :
32        """Opens the logging subsystem."""
33        syslog.openlog("PyKota", 0, syslog.LOG_LPR)
34       
35    def __del__(self) :   
36        """Ensures the logging subsystem is closed."""
37        syslog.closelog()
38       
39    def log_message(self, message, level="info") :
40        """Sends the message to syslog."""
41        try :
42            priority = getattr(syslog, "LOG_%s" % level.upper())
43        except AttributeError :   
44            # Bad priority name, we log this as a DEBUG message
45            priority = syslog.LOG_DEBUG
46        syslog.syslog(priority, message)
Note: See TracBrowser for help on using the browser.