def METHOD_NAME(self):
    """
    This functions searches within the audit trail
    It returns the audit information for the given search pattern
    arguments are key, value pairs as search patterns.
    :param outform: (optional) if set to "csv", than the token list will be given in CSV
        or: Usually the key=values will be locally AND concatenated.
            it a parameter or=true is passed, the filters will
            be OR concatenated.
        The Flexigrid provides us the following parameters:
            ('page', u'1'), ('rp', u'25'),
            ('sortname', u'number'),
            ('sortorder', u'asc'),
            ('query', u''), ('qtype', u'serial')]
    :return:
        JSON response or csv format
    """
    try:
        log.debug("[search] params: %r", self.request_params)
        checkPolicyPre("audit", "view", {})
        # remove the param outform (and other parameters that should not
        # be used for search!
        search_params = self.request_params.copy()
        for key in ["outform", "delimiter"]:
            if key in search_params:
                del search_params[key]
        output_format = (
            self.request_params.get("outform", "json") or "json"
        )
        delimiter = self.request_params.get("delimiter", ",") or ","
        audit_obj = current_app.audit_obj
        audit_query = AuditQuery(search_params, audit_obj)
        # ------------------------------------------------------------- --
        # check if we are running with sqlite which does not support
        # streaming responses
        stream_output = True
        db_uri = current_app.config["SQLALCHEMY_BINDS"]["auditdb"]
        if db_uri.startswith("sqlite"):
            stream_output = False
        if output_format == "csv":
            audit_iterator = CSVAuditIterator(audit_query, delimiter)
            mimetype = "text/csv"
            reponse_headers_args = {
                "_key": "Content-disposition",
                "_value": "attachment",
                "filename": "linotp-audit.csv",
            }
        else:
            audit_iterator = JSONAuditIterator(audit_query)
            mimetype = "application/json"
            reponse_headers_args = {}
        if stream_output:
            audit_output = stream_with_context(audit_iterator)
        else:
            audit_output = ""
            try:
                while True:
                    audit_output = audit_output + next(audit_iterator)
            except StopIteration:
                # continue if all data is joined
                pass
        streamed_response = Response(audit_output, mimetype=mimetype)
        if reponse_headers_args:
            streamed_response.headers.set(**reponse_headers_args)
        g.audit["success"] = True
        db.session.commit()
        return streamed_response
    except PolicyException as pe:
        log.error("[getotp] gettoken/getotp policy failedi: %r", pe)
        db.session.rollback()
        return sendError(response, pe, 1)
    except Exception as exx:
        log.error("[search] audit/search failed: %r", exx)
        db.session.rollback()
        return sendError(response, "audit/search failed", 0)