Пример #1
0
    def setLogLevel(self):

        """
        set the log level of a certain logger which is identified by
        the url parameter loggerName.

        example call:

            POST /maintenance/setLogLevel
            loggerName=linotp.lib.user
            level=10

        (sets the log level of the user library to DEBUG)
        if loggerName is omitted, the root logger is assumed.
        """

        # we check if the client cert was valid by looking for
        # the existance of an env variable. for apache this is
        # SSL_CLIENT_S_DN_CN. to support other servers we read
        # the name of the variable from the config

        env_var = getFromConfig('maintenance_verify_client_env_var', False)

        if env_var:

            client_cert = request.environ.get(env_var)

            if client_cert is None:
                abort(401)

        # ----------------------------------------------------------------------

        # if no logger name is supplied we default to '' (which translates
        # to the root logger in the python stdlib logging api)

        name = request.POST.get('loggerName', '')

        # ----------------------------------------------------------------------

        level_as_str = request.POST.get('level', '')

        if not level_as_str.isdigit():
            abort(400)

        level = int(level_as_str)

        # ----------------------------------------------------------------------

        set_logging_level(name, level)
        Session.commit()
Пример #2
0
    def setLogLevel(self):

        """
        set the log level of a certain logger which is identified by
        the url parameter loggerName.

        example call:

            POST /maintenance/setLogLevel
            loggerName=linotp.lib.user
            level=10

        (sets the log level of the user library to DEBUG)
        if loggerName is omitted, the root logger is assumed.
        """

        try:

            # if no logger name is supplied we default to '' (which translates
            # to the root logger in the python stdlib logging api)

            name = request.POST.get('loggerName', '')

            # ----------------------------------------------------------------

            level_as_str = request.POST.get('level', '')

            if not level_as_str.isdigit():
                raise Exception("'level' %r contains nondigits!")

            level = int(level_as_str)

            # ----------------------------------------------------------------------

            set_logging_level(name, level)
            Session.commit()
            return sendResult(response, True)

        except Exception as exx:
            Session.rollback()
            log.exception(exx)
            return sendError(response, exx, 1)

        finally:
            Session.close()
Пример #3
0
    def setLogLevel(self):

        """
        set the log level of a certain logger which is identified by
        the url parameter loggerName.

        example call:

            POST /maintenance/setLogLevel
            loggerName=linotp.lib.user
            level=10

        (sets the log level of the user library to DEBUG)
        if loggerName is omitted, the root logger is assumed.
        """

        try:

            # if no logger name is supplied we default to '' (which translates
            # to the root logger in the python stdlib logging api)

            name = self.request_params.get('loggerName', '')

            # ----------------------------------------------------------------

            try:
                level = self.request_params.get('level', 0)
                level = int(level)
            except ValueError as e:
                raise Exception("debug level {} contains nondigits!".format(level))

            # ----------------------------------------------------------------------

            set_logging_level(name, level)
            Session.commit()
            return sendResult(response, True)

        except Exception as exx:
            Session.rollback()
            log.exception(exx)
            return sendError(response, exx, 1)

        finally:
            Session.close()
Пример #4
0
    def setLogLevel(self):
        """
        set the log level of a certain logger which is identified by
        the url parameter loggerName.

        example call:

            POST /maintenance/setLogLevel
            loggerName=linotp.lib.user
            level=10

        (sets the log level of the user library to DEBUG)
        if loggerName is omitted, the root logger is assumed.
        """

        try:

            # if no logger name is supplied we default to '' (which translates
            # to the root logger in the python stdlib logging api)

            name = self.request_params.get('loggerName', '')

            # ----------------------------------------------------------------

            try:
                level = self.request_params.get('level', 0)
                level = int(level)
            except ValueError as e:
                raise Exception(
                    "debug level {} contains nondigits!".format(level))

            # ----------------------------------------------------------------------

            set_logging_level(name, level)
            db.session.commit()
            return sendResult(response, True)

        except Exception as exx:
            db.session.rollback()
            log.exception(exx)
            return sendError(response, exx, 1)