[py-dev] What's next for py.log?

holger krekel hpk at trillke.net
Tue Jun 21 19:22:30 CEST 2005


Hi Grig, 

On Tue, Jun 21, 2005 at 07:54 -0700, Grig Gheorghiu wrote:
> Do you think the core consumer and producer code will remain as is for
> py.log? 

I currently guess so, yes.  I still feel there will be some re-thinking
after more people have used it more.  Especially i think that the 
dispatching rules (how keywords are connected to consumers) will
have to become more flexible at some point.  Hum, coming to think
of it we might want to change 'setconsumer' into 'subscribe' 
and offer a way to specify if a subscriber will consume a message 
or just look at it.  This may also help with your multilogger 
use case. (Also see below for an example). 

> It seems to work pretty well. I might still sub-class the
> Producer class for my multiple-keyword needs -- but that can easily be
> done in my application code, without changing py.log itself.

Right.  

> Are you thinking about adding more consumer objects such as syslog,
> email, Win Events? If so, I can give some of them a shot.

syslog and win-events would probably be interesting whereas
email has IMO too custom needs to warrant caring for it in the
py lib at the moment.  For syslog, i think it is easiest and most
flexibel to just offer a py.log.Syslogger class: 

    class Syslog(...): 
        def __init__(self, facility, severity, prefix=""): 
            ... 
        def __call__(self, msg): 
            # send to syslog daemon, take minimal code from
            # logging module 

and then in application code one can do: 

    py.log.subscribe("* error", 
                     Syslog("user", "error", "myprog: "), 
                     consume=False)

so that all messages with an 'error' keyword in it would show up
in syslog.  This is an application of the 'subscribe' extension idea 
above in that you can 

a) have '*' meaning an arbitrary number of keywords 

b) consume=False means that this subscription will not consume 
   the message and other possible subscribers should still get 
   invoked for the same message 

> I'm also thinking about advertising py.log a little on my blog. Or
> should I refrain until the py release? Let me know what you think.

That would be great.  Personally, i feel that the exact API and 
especially the dispatching mechanisms will change a bit, though, 
considering the open questions from the above 'subscribe' idea. 
So it depends a bit. If you plan to introduce py.log then it is 
probably too early.  If you want to discuss and mention the ideas 
including examples a bit, it's a perfect time. 

cheers, 

    holger



More information about the Pytest-dev mailing list