ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Using logging module for conditional nested logs
by Reckoner other posts by this author
Nov 4 2009 11:45AM messages near this date
Re: problem in installing wxwidgets for python. | Re: Using logging module for conditional nested logs
Hi,

I am getting started with your logging module and I went through the
tutorial and know-how to create a top-level 'root' logger with the
appropriate handlers.

I have a number of functions,say,

def foo1()

def foo2()
   ...
   foo1() # foo2 calls foo1

and I know how to connect each of these functions to the 'root' logger
by doing something like

def foo1()
  logger  = getLogger('root.foo1')

but I want to arrange it so that foo1 adds to the logfile that foo2 is
using ONLY when foo2 calls foo1. In other words, if I do

def foo2()
  logger  = getLogger('root.foo2')

or

def foo1()
  logger  = getLogger('root.foo2.foo1')

it responds to the 'root' logger when I want it to respond to *any*
logger that is attached to foo2.

Then, the question is how can I set up foo1 to log to whatever logger
foo2 is using. The purpose of doing this is that I am interested in
capturing when and by whom foo1 is called in whatever logger foo2 is
using. So, if I attach a separate logger to a third function, say, foo3
(), then I can avoid reporting those instances when foo3 calls foo1.

I hope that made some sense.


-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Reckoner
Vinay Sajip
Vinay Sajip
Reckoner
Jean-Michel Pichavant

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved