Last change
on this file since 14154 was
14154,
checked in by sil, 12 years ago
|
See #11
- Narrowed down number of Django-versions as a dependency
- Changed targets of docs, config-, data-, and executable-files to install
- Now installable in a virtual environment
|
File size:
980 bytes
|
Line | |
---|
1 | import logging |
---|
2 | import logging.config |
---|
3 | |
---|
4 | |
---|
5 | class Logger: |
---|
6 | """ |
---|
7 | A logging facility, implemented with the borg design pattern. Makes |
---|
8 | use of the Python logging lib, see: |
---|
9 | http://docs.python.org/library/logging.html |
---|
10 | """ |
---|
11 | __shared_state = {} |
---|
12 | |
---|
13 | # Check for existence of a global logging object, otherwise make one |
---|
14 | if 'logger' not in __shared_state.keys(): |
---|
15 | #TODO: think about a (better) way to make this dynamic: |
---|
16 | import site |
---|
17 | logging.config.fileConfig('%s/etc/cmt/logging.conf'%site.sys.prefix) |
---|
18 | __shared_state['logger'] = logging.getLogger('cli') |
---|
19 | |
---|
20 | def __init__(self): |
---|
21 | """ |
---|
22 | Assigns the global __shared_state to __dict__ to be able to use |
---|
23 | the class like a singleton. |
---|
24 | """ |
---|
25 | self.__dict__ = self.__shared_state |
---|
26 | |
---|
27 | def getLogger(self): |
---|
28 | """ |
---|
29 | Returns the only logger instance (or state, to be exactly). |
---|
30 | """ |
---|
31 | return self.__dict__['logger'] |
---|
Note: See
TracBrowser
for help on using the repository browser.