[695] | 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$ |
---|
[773] | 17 | # Revision 1.4 2003/02/09 13:05:43 jalet |
---|
| 18 | # Internationalization continues... |
---|
| 19 | # |
---|
[698] | 20 | # Revision 1.3 2003/02/05 22:10:29 jalet |
---|
| 21 | # Typos |
---|
| 22 | # |
---|
[697] | 23 | # Revision 1.2 2003/02/05 22:02:22 jalet |
---|
| 24 | # __import__ statement didn't work as expected |
---|
| 25 | # |
---|
[695] | 26 | # Revision 1.1 2003/02/05 21:28:17 jalet |
---|
| 27 | # Initial import into CVS |
---|
| 28 | # |
---|
| 29 | # |
---|
| 30 | # |
---|
| 31 | |
---|
| 32 | import sys |
---|
| 33 | |
---|
| 34 | class PyKotaLoggingError(Exception): |
---|
| 35 | """An exception for logging related stuff.""" |
---|
| 36 | def __init__(self, message = ""): |
---|
| 37 | self.message = message |
---|
| 38 | Exception.__init__(self, message) |
---|
| 39 | def __repr__(self): |
---|
| 40 | return self.message |
---|
| 41 | __str__ = __repr__ |
---|
| 42 | |
---|
| 43 | def openLogger(config) : |
---|
| 44 | """Returns the appropriate logger subsystem object.""" |
---|
| 45 | backend = config.getLoggingBackend() |
---|
| 46 | try : |
---|
[698] | 47 | if not backend.isalpha() : |
---|
[697] | 48 | # don't trust user input |
---|
| 49 | raise ImportError |
---|
| 50 | exec "from pykota.loggers import %s as loggingbackend" % backend.lower() |
---|
[695] | 51 | except ImportError : |
---|
[773] | 52 | raise PyKotaLoggingError, _("Unsupported logging subsystem %s") % backend |
---|
[695] | 53 | else : |
---|
[697] | 54 | return getattr(loggingbackend, "Logger")() |
---|