當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。