当前位置: 首页>>代码示例>>Python>>正文


Python access_log.info方法代码示例

本文整理汇总了Python中tornado.log.access_log.info方法的典型用法代码示例。如果您正苦于以下问题:Python access_log.info方法的具体用法?Python access_log.info怎么用?Python access_log.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.log.access_log的用法示例。


在下文中一共展示了access_log.info方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: log_request

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def log_request(self, handler):
        """写一个完成的HTTP 请求到日志中.

        默认情况下会写到python 根(root)logger. 要改变这种行为
        无论是子类应用和复写这个方法, 或者传递一个函数到应用的
        设置字典中作为 ``log_function``.
        """
        if "log_function" in self.settings:
            self.settings["log_function"](handler)
            return
        if handler.get_status() < 400:
            log_method = access_log.info
        elif handler.get_status() < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * handler.request.request_time()
        log_method("%d %s %.2fms", handler.get_status(),
                   handler._request_summary(), request_time) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:21,代码来源:web.py

示例2: log_request

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def log_request(self, handler: RequestHandler) -> None:
        """Writes a completed HTTP request to the logs.

        By default writes to the python root logger.  To change
        this behavior either subclass Application and override this method,
        or pass a function in the application settings dictionary as
        ``log_function``.
        """
        if "log_function" in self.settings:
            self.settings["log_function"](handler)
            return
        if handler.get_status() < 400:
            log_method = access_log.info
        elif handler.get_status() < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * handler.request.request_time()
        log_method(
            "%d %s %.2fms",
            handler.get_status(),
            handler._request_summary(),
            request_time,
        ) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:26,代码来源:web.py

示例3: log_request

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def log_request(self, handler):
        """Writes a completed HTTP request to the logs.

        By default writes to the python root logger.  To change
        this behavior either subclass Application and override this method,
        or pass a function in the application settings dictionary as
        ``log_function``.
        """
        if "log_function" in self.settings:
            self.settings["log_function"](handler)
            return
        if handler.get_status() < 400:
            log_method = access_log.info
        elif handler.get_status() < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * handler.request.request_time()
        log_method("%d %s %.2fms", handler.get_status(),
                   handler._request_summary(), request_time) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:22,代码来源:web.py

示例4: reset_is_running_on_all_spider

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def reset_is_running_on_all_spider( coll_model ) :
	"""
	reset is_running on all spiders to avoid errors if app shut down while one spider was running 
	"""

	print ()

	app_log.warning('>>> reset_is_running_on_all_spider ... ')
	
	# find if any spider was running
	running_spiders = coll_model.find({"scraper_log.is_running" : True})
	app_log.info(">>> running_spiders : \n %s" , list(running_spiders) )

	coll_model.update_many({'scraper_log.is_running' : True }, {"$set": {'scraper_log.is_running' : False }})

	# if list(running_spiders) != [] : 

	# 	app_log.warning('>>> reset_is_running_on_all_spider / some spiders were blocked in is_running == True ... ')
	# 	app_log.warning('>>> spiders are : \n %s', pformat(list(running_spiders)) )

	# 	coll_model.update({"scraper_log.is_running":True}, {"$set" : {"scraper_log.is_running" : False }})
	
	# print 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:25,代码来源:main.py

示例5: _log

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def _log(self, status_code, request):
        if status_code < 400:
            log_method = access_log.info
        elif status_code < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * request.request_time()
        summary = request.method + " " + request.uri + " (" + \
            request.remote_ip + ")"
        log_method("%d %s %.2fms", status_code, summary, request_time) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:13,代码来源:wsgi.py

示例6: _log

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def _log(self, status_code: int, request: httputil.HTTPServerRequest) -> None:
        if status_code < 400:
            log_method = access_log.info
        elif status_code < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * request.request_time()
        assert request.method is not None
        assert request.uri is not None
        summary = request.method + " " + request.uri + " (" + request.remote_ip + ")"
        log_method("%d %s %.2fms", status_code, summary, request_time) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:14,代码来源:wsgi.py

示例7: log_request

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def log_request(handler):
    try:
        request = handler.request
        location_info = referer_info = user_agent_info = ''
        status_code = handler.get_status()
        if status_code < 400:
            log_method = access_log.info
            if status_code in (301, 302, 307):
                location = handler._headers.get('Location')
                if location:
                    location_info = '\n\tLocation: ' + location
        elif status_code < 500:
            log_method = access_log.warning
            headers = request.headers
            referer = headers.get('Referer')
            if referer:
                referer = referer.replace('"', '')
                referer_info = '\n\tReferer url: ' + referer
            user_agent = headers.get('User-Agent')
            if user_agent:
                user_agent = user_agent.replace('"', '')
                user_agent_info = '\n\tUser agent: ' + user_agent
        else:
            log_method = access_log.error

        request_time = request.request_time()
        log_method("%d %s %.2fms%s%s%s", status_code,
                   handler._request_summary(), request_time * 1000.0,
                   location_info, referer_info, user_agent_info)
    except Exception:
        logging.exception('failed to log request') 
开发者ID:keakon,项目名称:Doodle,代码行数:33,代码来源:logger.py

示例8: _log

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def _log(self, status_code, request):
        if status_code < 400:
            log_method = access_log.info
        elif status_code < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error

        timestamp = ut.timestamp()
        request_time = 1000.0 * request.request_time()
        log_method(
            "WALL=%s STATUS=%s METHOD=%s URL=%s IP=%s TIME=%.2fms",
            timestamp,
            status_code, request.method,
            request.uri, request.remote_ip, request_time) 
开发者ID:Erotemic,项目名称:ibeis,代码行数:17,代码来源:app.py

示例9: __save_secret

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def __save_secret(self, secret):
        key = 'vps-' + self.__remote_ip()
        redis = await aioredis.create_redis(self.redis_addr, timeout=REDIS_TIMEOUT)
        access_log.info('adding: ({}, {})'.format(key, secret))
        await redis.set(key, secret, expire=30) # register secret
        redis.close()
    ##
    ## @brief      { function_description }
    ## 
开发者ID:InsecurityAsso,项目名称:inshack-2018,代码行数:11,代码来源:virtual_printer_wrapper.py

示例10: __load_secret

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def __load_secret(self):
        key = 'vps-' + self.__remote_ip()
        redis = await aioredis.create_redis(self.redis_addr, timeout=REDIS_TIMEOUT)
        secret = await redis.get(key)
        redis.close()
        access_log.info('retrieving: ({}, {})'.format(key, secret))
        return secret
    ##
    ## @brief      { function_description }
    ## 
开发者ID:InsecurityAsso,项目名称:inshack-2018,代码行数:12,代码来源:virtual_printer_wrapper.py

示例11: __serial_number

# 需要导入模块: from tornado.log import access_log [as 别名]
# 或者: from tornado.log.access_log import info [as 别名]
def __serial_number(self):
        data = self.request.body

        if data[0:3] == b'sn=':
            secret = data[3:]

            try:
                saved_secret = await self.__load_secret()
            except Exception as e:
                self.__reject("[__load_secret:exception] service failed to "
                              "save the secret. Request timed-out.\nPlease "
                              "contact an admin. Redis server might be down.")
                return

            if saved_secret is None:
                self.__reject("Too late, you must submit your serial-number "
                              "within a timeframe of 25 seconds after your "
                              "image was printed.")
                return

            if secret == saved_secret:
                access_log.info("{} gets a flag!".format(self.__remote_ip()))
                self.__accept("Good job ! DO NOT LEAK SECRET FILES BY "
                              "PRINTING THEM ! You can validate with: "
                              "{}".format(self.flag))
                return

            access_log.info("received secret is [{}] and saved_secret is [{}]; mismatch!".format(secret, saved_secret))
            self.__reject("Wrong secret... Try again :)")
            return

        self.__reject("could not find the serial number.\nPlease upload data "
                      "using the following command: curl -d "
                      "'sn=<b64encoded_serial_number>' "
                      "http://...:.../serial-number")
        return
    ##
    ## @brief      { function_description }
    ## 
开发者ID:InsecurityAsso,项目名称:inshack-2018,代码行数:41,代码来源:virtual_printer_wrapper.py


注:本文中的tornado.log.access_log.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。