class instance of Producer():
Log producer API which sends messages to be logged
to a 'consumer' object, which then prints them to stdout,
stderr, files, etc.
no source available
class attributes and properties:
keywords: ('default',)
keywords2consumer: {'default': <function default_consumer at 0x10518930>}
methods:
def __init__(self, keywords):
*no docstring available*
arguments:
- self: <UNKNOWN>
- keywords: <UNKNOWN>
return value:
<UNKNOWN>
source: log/producer.py
|
def __init__(self, keywords): |
if isinstance(keywords, str): |
keywords = tuple(keywords.split()) |
self.keywords = keywords | |
def get_consumer(self, keywords):
return a consumer matching keywords
tries to find the most suitable consumer by walking, starting from
the back, the list of keywords, the first consumer matching a
keyword is returned (falling back to py.log.default)
arguments:
- self: <UNKNOWN>
- keywords: <UNKNOWN>
return value:
<UNKNOWN>
source: log/producer.py
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | |
def get_consumer(self, keywords): |
""" return a consumer matching keywords |
|
tries to find the most suitable consumer by walking, starting from |
the back, the list of keywords, the first consumer matching a |
keyword is returned (falling back to py.log.default) |
""" |
for i in range(len(self.keywords), 0, -1): |
try: |
return self.keywords2consumer[self.keywords[:i]] |
except KeyError: |
continue |
return self.keywords2consumer.get('default', default_consumer) | |
def set_consumer(self, consumer):
register a consumer matching our own keywords
arguments:
- self: <UNKNOWN>
- consumer: <UNKNOWN>
return value:
<UNKNOWN>
source: log/producer.py
|
def set_consumer(self, consumer): |
""" register a consumer matching our own keywords """ |
self.keywords2consumer[self.keywords] = consumer | |
def __call__(self, *args):
write a message to the appropriate consumer(s)
arguments:
return value:
<UNKNOWN>
source: log/producer.py
|
def __call__(self, *args): |
""" write a message to the appropriate consumer(s) """ |
func = self.get_consumer(self.keywords) |
if func is not None: |
func(self.Message(self.keywords, args)) | |
def __getattr__(self, name):
*no docstring available*
arguments:
- self: <UNKNOWN>
- name: <UNKNOWN>
return value:
<UNKNOWN>
source: log/producer.py
|
def __getattr__(self, name): |
if '_' in name: |
raise AttributeError, name |
producer = self.__class__(self.keywords + (name,)) |
setattr(self, name, producer) |
return producer | |
def __repr__(self):
*no docstring available*
arguments:
return value:
<UNKNOWN>