import six


def _prefix(logfn):
    """Add the client IP to a log message"""
    def wrapped(self, message):
        if isinstance(message, six.string_types):
            message = message.rstrip()
            if not message:
                message = "  <empty msg>"
        message = "  {}: {}".format(self.ipAddress, message)
        logfn(self, message)
    return wrapped