'Helper function to write data to the log file from the XMLRPC remote implementation.
Takes various optional parameters that should be supplied when known.'

def _log(self, msg, user=None, token=None, name=None, object_id=None, attribute=None, debug=False, error=False):

    m_user = '?'
    if (user is not None):
        m_user = user
    if (token is not None):
        try:
            m_user = self.get_user_from_token(token)
        except:
            m_user = '???'
    msg = ('REMOTE    %s;    user(%s)' % (msg, m_user))
    if (name is not None):
        msg = ('%s;    name(%s)' % (msg, name))
    if (object_id is not None):
        msg = ('%s;    object_id(%s)' % (msg, object_id))
    if attribute:
        msg = ('%s;    attribute(%s)' % (msg, attribute))
    if error:
        logger = self.logger.error
    elif debug:
        logger = self.logger.debug
    else:
        logger = self.logger.info
    logger(msg)
