def METHOD_NAME(self, msg, type='debug'):
    handler = dict(
        debug=self.annex.debug,
        info=self.annex.info,
        error=self.annex.error,
    ).get(type, self.annex.debug)
    # ensure that no multiline messages are sent, they would cause a
    # protocol error
    msg = msg.replace('\n', '\\n')
    try:
        handler(msg)
    except ProtocolError:
        # INFO not supported by annex version.
        # If we can't have an actual info message, at least have a
        # debug message.
        self.annex.debug(msg)