Revision 707, 1.2 kB
(checked in by jalet, 21 years ago)
|
Name conflict
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
Rev | Line | |
---|
[707] | 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.1 2003/02/05 23:09:20 jalet |
---|
| 18 | # Name conflict |
---|
| 19 | # |
---|
| 20 | # |
---|
| 21 | # |
---|
| 22 | |
---|
| 23 | import sys |
---|
| 24 | import syslog |
---|
| 25 | |
---|
| 26 | class Logger : |
---|
| 27 | """A logger class which logs to syslog.""" |
---|
| 28 | def __init__(self) : |
---|
| 29 | """Opens the logging subsystem.""" |
---|
| 30 | syslog.openlog("PyKota", 0, syslog.LOG_LPR) |
---|
| 31 | |
---|
| 32 | def __del__(self) : |
---|
| 33 | """Ensures the logging subsystem is closed.""" |
---|
| 34 | syslog.closelog() |
---|
| 35 | |
---|
| 36 | def log_message(self, message, level) : |
---|
| 37 | """Sends the message to syslog.""" |
---|
| 38 | try : |
---|
| 39 | priority = getattr(syslog, "LOG_%s" % level.upper()) |
---|
| 40 | except AttributeError : |
---|
| 41 | # Bad priority name, we log this as a DEBUG message |
---|
| 42 | priority = syslog.LOG_DEBUG |
---|
| 43 | syslog.syslog(priority, message) |
---|