Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
logbook: Only handlers can format extra data
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Elsdörfer  
View profile  
 More options Apr 15 2012, 8:41 am
From: Michael Elsdörfer <elsdoer...@gmail.com>
Date: Sun, 15 Apr 2012 05:41:30 -0700 (PDT)
Local: Sun, Apr 15 2012 8:41 am
Subject: logbook: Only handlers can format extra data

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »