Logging

There is an abstract class that can be subclassed to allow per class or even per instance logging.

class pypet.pypetlogging.HasLogger[source]

Abstract super class that automatically adds a logger to a class.

To add a logger to a sub-class of yours simply call myobj._set_logger(name). If name=None the logger name is picked as follows:

self._logger = logging.getLogger(type(self).__name__)

The logger can be accessed via myobj._logger.

__getstate__()[source]

Called for pickling.

Removes the logger to allow pickling and returns a copy of __dict__.

__setstate__(statedict)[source]

Called after loading a pickle dump.

Restores __dict__ from statedict and adds a new logger.

__weakref__

list of weak references to the object (if defined)

_set_logger(name=None)[source]

Adds a logger with a given name.

If no name is given, name is constructed as type(self).__name__.