Package rdkit :: Package Logger :: Module Logger :: Class Logger
[hide private]
[frames] | no frames]

Class Logger

source code

object --+
         |
        Logger

This is the actual wrapper class.

The wrapper is fairly thin; it only has one methods of its own:

  - _LoggerGetLog()

and then several instance variables:

  - _loggerFlushCommand

  - _loggerClass

  - _loggerObj

  - _loggerCommandLog

  - _loggerIgnore

These names were chosen to minimize the likelihood of a collision
 with the attributes of a wrapped class.  Obviously... ;-)

The general idea of using this is that you wrap a class in the logger,
  and then use the class as you normally would.  Whenever you want to 
  get the contents of the log (for example after running your program for
  a while), you can call _loggerCommandLog.  The resulting list can be
  played back in another (or the same) object using the replay() function
  defined below.

The logger can, optionally, be set to flush its log whenever a method with
  a particular name is invoked.  For example, you may want to be wrapping
  some kind of drawing canvas and want to reset the log whenever the canvas
  is cleared because there's no point in storing commands which will have
  no effect on the final drawing.

**Note**

  because of the way I've worked this, the log will actually be flushed
  whenever the client program accesses the flush method, it need not be invoked.
  i.e. if the loggerFlushCommand is 'foo', then doing either wrappedObj.foo() or
  wrappedObj.foo will reset the log.  This is undesirable and will most likely
  be fixed in a future version

Instance Methods [hide private]
 
__init__(self, klass, *args, **kwargs)
Constructor
source code
 
_LoggerGetLog(self)
Returns the contents of the command log as a python list
source code
 
__getattr__(self, which)
here's where the logging of method invocations takes place
source code
 
__setattr__(self, which, val)
setattr calls (i.e.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, klass, *args, **kwargs)
(Constructor)

source code 
Constructor

**Arguments**

  The one required argument here is _klass_, which is the class
  to be wrapped.

**Optional Keyword Arguments**

  - loggerFlushCommand: the name of the attribute which will flush the log

  - loggerIgnore: a list of regexps defining methods which should not be
    logged

**All other arguments are passed to the constructor for _klass_ **

Overrides: object.__init__

__setattr__(self, which, val)

source code 
setattr calls (i.e. wrappedObject.foo = 1) are also logged

    

Overrides: object.__setattr__