fine grain logging cotrol

Eric S. Johansson esj at harvee.org
Thu Mar 22 13:39:21 CET 2007


I need to to be able to conditionally log based on the method the log 
statement is in and one other factor like a log level.  in order to do 
so, I need to be able to automatically find out the name of the method 
and its class but I haven't found out how to do that yet.

for example,

class catus(Felis):
   def Siamese_cat( yowl, purr, demand_food):

     ...
     log("state of litter box %s"% litter_box.smell, level = 1)


If the table of methods logged contains "catus.Siamese_cat", then I 
would expect to see the output of the log statements in a log file.  If 
not then I wouldn't see anything in the log.

Has somebody done this already?  Is it even possible to do without 
manually adding the class and method information for every log statement?

a related question is using signals for reloading configurations etc.  I 
have to find any good examples of how to use signals to cause a 
long-running process to reload external data.  Any good pointers?


--- eric







More information about the Python-list mailing list