Mercurial > p > roundup > code
comparison roundup/instance.py @ 2397:fa50e1347397
added basic logging support
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 08 Jun 2004 05:29:18 +0000 |
| parents | c77483d2cda4 |
| children | eeadb59213d8 |
comparison
equal
deleted
inserted
replaced
| 2396:39cdddd313ca | 2397:fa50e1347397 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: instance.py,v 1.13 2004-05-10 00:34:48 richard Exp $ | 18 # $Id: instance.py,v 1.14 2004-06-08 05:29:18 richard Exp $ |
| 19 | 19 |
| 20 '''Tracker handling (open tracker). | 20 '''Tracker handling (open tracker). |
| 21 | 21 |
| 22 Backwards compatibility for the old-style "imported" trackers. | 22 Backwards compatibility for the old-style "imported" trackers. |
| 23 ''' | 23 ''' |
| 24 __docformat__ = 'restructuredtext' | 24 __docformat__ = 'restructuredtext' |
| 25 | 25 |
| 26 import os | 26 import os |
| 27 from roundup import rlog | |
| 27 | 28 |
| 28 class Vars: | 29 class Vars: |
| 29 ''' I'm just a container ''' | 30 ''' I'm just a container ''' |
| 30 | 31 |
| 31 class Tracker: | 32 class Tracker: |
| 89 for required in 'config open init Client MailGW'.split(): | 90 for required in 'config open init Client MailGW'.split(): |
| 90 if not hasattr(tracker, required): | 91 if not hasattr(tracker, required): |
| 91 raise TrackerError, \ | 92 raise TrackerError, \ |
| 92 'Required tracker attribute "%s" missing'%required | 93 'Required tracker attribute "%s" missing'%required |
| 93 | 94 |
| 95 # init the logging | |
| 96 config = tracker.config | |
| 97 if hasattr(config, 'LOGGING_CONFIG'): | |
| 98 try: | |
| 99 import logging | |
| 100 config.logging = logging | |
| 101 except ImportError, msg: | |
| 102 raise TrackerError, 'Python logging module unavailable: %s'%msg | |
| 103 config.logging.fileConfig(config.LOGGING_CONFIG) | |
| 104 elif hasattr(config, 'LOGGING_FILENAME'): | |
| 105 config.logging = rlog.BasicLogging() | |
| 106 config.logging.setFile(config.LOGGING_FILENAME) | |
| 107 if hasattr(config, 'LOGGING_LEVEL'): | |
| 108 config.logging.setLevel(config.LOGGING_LEVEL) | |
| 109 else: | |
| 110 config.logging = rlog.BasicLogging() | |
| 111 config.logging.setLevel('ERROR') | |
| 112 | |
| 94 return tracker | 113 return tracker |
| 95 | 114 |
| 96 OldStyleTrackers = OldStyleTrackers() | 115 OldStyleTrackers = OldStyleTrackers() |
| 97 def open(tracker_home): | 116 def open(tracker_home): |
| 98 if os.path.exists(os.path.join(tracker_home, 'dbinit.py')): | 117 if os.path.exists(os.path.join(tracker_home, 'dbinit.py')): |
