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.3 2003/02/27 22:55:20 jalet |
---|
18 | # WARN log priority doesn't exist. |
---|
19 | # |
---|
20 | # Revision 1.2 2003/02/05 23:47:54 jalet |
---|
21 | # Forgotten default argument |
---|
22 | # |
---|
23 | # Revision 1.1 2003/02/05 23:09:20 jalet |
---|
24 | # Name conflict |
---|
25 | # |
---|
26 | # |
---|
27 | # |
---|
28 | |
---|
29 | import sys |
---|
30 | import syslog |
---|
31 | |
---|
32 | class Logger : |
---|
33 | """A logger class which logs to syslog.""" |
---|
34 | def __init__(self) : |
---|
35 | """Opens the logging subsystem.""" |
---|
36 | syslog.openlog("PyKota", 0, syslog.LOG_LPR) |
---|
37 | |
---|
38 | def __del__(self) : |
---|
39 | """Ensures the logging subsystem is closed.""" |
---|
40 | syslog.closelog() |
---|
41 | |
---|
42 | def log_message(self, message, level="info") : |
---|
43 | """Sends the message to syslog.""" |
---|
44 | priority = getattr(syslog, "LOG_%s" % level.upper(), syslog.LOG_DEBUG) |
---|
45 | syslog.syslog(priority, message) |
---|