print line number and source filename
Vinay Sajip
vinay_sajip at yahoo.co.uk
Thu Jun 24 14:06:48 EDT 2010
On Jun 24, 4:07 am, Peng Yu <pengyu... at gmail.com> wrote:
> %(module)s only print to "__init__". However, I need the fullname
> a.b.__init__. I looked at the manual, but I don't see what format
> string I should supply. Would you please let me know?
>
Did you look at this part of the documentation?
http://docs.python.org/library/logging.html#formatter-objects
You should use in each of your modules
logger = logging.getLogger(__name__)
and in the format string, use %(name)s. This will give "a.b" for a
logger defined in <pythonpath>/a/b/__init__.py, "a" for a logger
defined in <pythonpath>/a/__init__.py, "a.b.c" for a logger defined in
<pythonpath>/a/b/c.py, and so on.
Regards,
Vinay Sajip
More information about the Python-list
mailing list