[py-dev] Logging in the py library
holger krekel
hpk at trillke.net
Sat Jun 11 18:14:27 CEST 2005
Hi Grig,
On Sat, Jun 11, 2005 at 08:54 -0700, Grig Gheorghiu wrote:
> --- holger krekel <hpk at trillke.net> wrote:
> > - we should merge the py.trace and py.log namespaces
> > e.g. by saying that all non-underscore and/or all lowercase
> > names are keywords and the rest are functions/classes, e.g.
> >
> > py.log.debug("hello world") # as current py.trace.*
> > py.log.set_logger('debug', py.log.FileLogger(path, append=True))
> >
> > and maybe forget about the [...] and getitem-trick alltogether.
> > Keyword arguments provide nice flexibility for future features
> > which __getitem__ can't.
> > ...
> > - it seems you prefer the 'py.log' naming. I am fine with that.
>
> I didn't intend to replace py.trace with py.log. I was thinking that
> there would be 2 orthogonal name spaces: py.trace for specifying the
> messages/keywords to be logged, and py.log for choosing the
> loggers/filters/etc.
I think that having two root-level namespaces is too much.
Let's merge the two, especially since the py/__init__.py
mechanism allows to keep things in separate files nevertheless.
Hum, coming to think of it you may need to tweak the __init__.py
file definitions for the time being to something like:
'py.log.debug': ('./misc/log.py', 'debug'),
'py.log.warn': ('./misc/log.py', 'warn'),
'py.log.set_logger': ('./misc/log.py', 'set_logger'),
'py.log.File': ('./misc/log_support.py', 'File'),
I know that this means that py.log (py.trace currently) would
loose the ability to dynamically add keywords but that may
actually be a good thing (e.g. to prevent typos) and it's
only true at "root-level". I.e. one can still do:
debug = py.log.debug.execnet
and actually, if we need it, we can just add a clean helper like:
py.log.Tracer("debug execnet gateway")
which would return a py.log Tracer with exactly the given
keywords etc.pp. Btw, we might want to speak about "Tracers"
and "Loggers" to distinguish the producing from the consuming
part. If you don't have some better terminology in mind.
Did i mention that the other half of my programming time that
i don't spend with testing, i spent with shuffling names? :-)
cheers,
holger
More information about the py-dev
mailing list