<NME> __init__.py
<BEF> #!/usr/bin/env python

import os
import sys

class SerfHandler(object):
    def __init__(self):
        self.name = os.environ['SERF_SELF_NAME']
        self.role = os.environ['SERF_SELF_ROLE']
        if os.environ['SERF_EVENT'] == 'user':
            self.event = os.environ['SERF_USER_EVENT']
        else:
            self.event = os.environ['SERF_EVENT'].replace('-', '_')

    def log(self, message):
        print(message)


class SerfHandlerProxy(SerfHandler):
class SerfHandlerProxy(SerfHandler):

    def __init__(self):
        super(SerfHandlerProxy, self).__init__()
        self.handlers = {}

    def register(self, role, handler):
        self.handlers[role] = handler

    def get_klass(self):
        klass = False
        if self.role in self.handlers:
            klass = self.handlers[self.role]
        elif 'default' in self.handlers:
            klass = self.handlers['default']
        return klass

    def run(self):
        klass = self.get_klass()
        if not klass:
            self.log("no handler for role")
        else:
            try:
                getattr(klass, self.event)()
            except AttributeError:
                self.log("event not implemented by class")

<MSG> Instead of printing use the logging framework.
<DFF> @@ -2,18 +2,20 @@
 
 import os
 import sys
+import logging
 
 class SerfHandler(object):
     def __init__(self):
         self.name = os.environ['SERF_SELF_NAME']
         self.role = os.environ['SERF_SELF_ROLE']
+        self.logger = logging.getLogger(type(self).__name__)
         if os.environ['SERF_EVENT'] == 'user':
             self.event = os.environ['SERF_USER_EVENT']
         else:
             self.event = os.environ['SERF_EVENT'].replace('-', '_')
 
     def log(self, message):
-        print(message)
+        self.logger.info(message)
 
 
 class SerfHandlerProxy(SerfHandler):

Instead of printing use the logging framework.