Source line number for log purpose (newbie)

T. C. Mits 71351.356 at compuserve.com
Sat Sep 25 10:27:06 EDT 1999


Ok.  I looked in Exception library and don't see the relevance.   I am
logging normal code, not exceptions.   For example,
log.prtl( SERIOUS, "About to create dest file %s" % newfilename)

In this case, to help maintainers of the code, I want to also log the line
number where this statement is found in the source.

I'm now thinking this has to done by digging into the Python extension
mechanisms and system variables deep in the system?


T. C. Mits <71351.356 at compuserve.com> wrote in message
news:7sig2t$oar$1 at ssauraaa-i-1.production.compuserve.com...
> Thanks, I'll look at the Exception module again.
>
> Gerrit Holl <gerrit.holl at pobox.com> wrote in message
> news:19990925130431.B11328 at optiplex.palga.uucp...
> > T. C. Mits:
> > > In c there was a way to get the current source line number via a
macro,
> > > __LINE__.
> > >
> > > I need to be able to do the same thing.  I created a logger class that
> uses
> > > a level setting.  At high levels I want to
> > > log the source line number where the inline log.prtl( level, msg)
method
> > > call appears.
> > >
> > > I'm sure this is easy but am getting lost digging through the Python
> source
> > > and docs.
> > >
> >
> > That's possible via the 'Exception' module.
> >
> > regards,
> > Gerrit.
> > --
> > RTFM: Read That FreshMeat
> >
> >
>
>






More information about the Python-list mailing list