It seems to me that is somewhat of a design flaw.
Say I have a number of threads, each serving a client connection. Now when
the thread starts, I can say:
logbook.Processor(self.extra_info).push_thread()
This processor would add the user id to the record. Now, in various places
within the thread, I can simply call the logbook log functions, with the
user id always being automatically injected.
The problem is getting the extra info formatted. The handler that I setup
at the application-level knows nothing of these specific extra fields of a
sub-component of the app, nor should it.
I am considering attaching a handler to the logger that only reformats the
message:
class ExtraFormattingHandler(logbook.Handler):
def __init__(self):
super(ExtraFormattingHandler, self).__init__(bubble=True)
def emit(self, record):
record.message = '....'
log = logbook.Logger(__name__)
log.handlers.append(ExtraFormattingHandler())
However, that feels a bit hacky. Is there a better way to deal with this?
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pocoo-libs/-/gHsDK3ec1cMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.