[py-dev] Logging in the py library

holger krekel hpk at trillke.net
Sat Jun 11 14:03:25 CEST 2005


Hey Grig, 

On Fri, Jun 10, 2005 at 16:09 -0700, Grig Gheorghiu wrote:
> I just svn commit-ed 2 files: misc/log.py and misc/testing/test_log.py.
> I tried to keep things as simple as possible and as close to the spirit
> of py.trace as possible, while using the logging module as the
> back-end. Please consider this experimental code. I'll be working on it
> throughout the weekend. 
> 
> Comments/suggestions are very welcome, vital actually :-)

first of all, thanks for helping!  It looks nice so far 
yet i am giving you detailed feedback and criticism
as requested.  And please, you don't need to excuse 
yourself for anything.  This is a technical discussion :-) 

- 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. 

  Note that 'set_logger' and 'FileLogger' would not be regarded as 
  a keyword because they contain underscores and are not all lowercase. 

  We may want to consider to keep the FileLogger() and similar 
  names very close to the logging module.  But please don't 
  expose the Logging module's classes directly but just
  delegate to them underlyingly. 

- it seems you prefer the 'py.log' naming.  I am fine with that. 

- make sure that all your files have the 'svn:eol-style'
  property set to 'native' with e.g. 

      svn propset 'svn:eol-style' native FILE1 FILE2" 

- it should always be easy for an application to completely 
  take over logging (as the current py.trace allows) and not
  care about custom loggers or even hierachies. So something
  like 

    def myfunction(message): 
        ... 
    py.log.set_logger("", myfunction) 

  should be enough to have all messages routed through 
  my function. 

- for writing tests, please don't just create random   
  files here and there.  Use something like: 

    dir = py.test.ensuretemp("logtest") 
    p = dir.join('py_stdout') 

  and make sure that such paths can always be passed to 
  py.log functions and classes, e.g. by str()ing path-arguments 
  them early. 

- please keep the basic py.trace functionality (renamed to 
  py.log to your likening) self-contained and put the extra 
  stuff (like FileLogger etc.pp) into a log_support.py file.  
  I'd really like to use the basic mechanism from py.execnet 
  very early on. 

- i reserve the right to tweak the final exact names 
  because i really want the py lib to have a tight concise 
  namespace organization.  So for example. 

    py.log.File(...) might be preferable to the duplication in 
    py.log.FileLogger(...) 

  from my anal naming point of view :-) 

cheers, 

    holger


More information about the py-dev mailing list