Python tornado.log.app_log.warning() Examples
The following are 30
code examples of tornado.log.app_log.warning().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado.log.app_log
, or try the search function
.
Example #1
Source File: main.py From OpenScraper with MIT License | 6 votes |
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
Example #2
Source File: web.py From tornado-zh with MIT License | 6 votes |
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)
Example #3
Source File: web.py From tornado-zh with MIT License | 6 votes |
def log_exception(self, typ, value, tb): """复写来自定义未捕获异常的日志. 默认情况下 `HTTPError` 的日志实例作为警告(warning)没有堆栈追踪(在 ``tornado.general`` logger), 其他作为错误(error)的异常带有堆栈 追踪(在 ``tornado.application`` logger). .. versionadded:: 3.1 """ if isinstance(value, HTTPError): if value.log_message: format = "%d %s: " + value.log_message args = ([value.status_code, self._request_summary()] + list(value.args)) gen_log.warning(format, *args) else: app_log.error("Uncaught exception %s\n%r", self._request_summary(), self.request, exc_info=(typ, value, tb))
Example #4
Source File: main.py From OpenScraper with MIT License | 6 votes |
def backup_mongo_collection(coll, filepath) : """ dumps all documents in collection in _backups_collections """ app_log.warning('>>> backup_mongo_collection ... ') cursor = coll.find({}) backup_file = open(filepath, "w") backup_file.write('[') for document in cursor: backup_file.write(json.dumps(document,indent=4, default=json_util.default)) backup_file.write(',') backup_file.write(']') ### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### ### MAIN TORNADO APPLICATION WRAPPER
Example #5
Source File: core_classes.py From OpenScraper with MIT License | 6 votes |
def __init__(self, **kwargs) : print app_log.warning("== UserClass ... ") app_log.warning("== UserClass / fields from USER_CORE_FIELDS ... ") for user_field in USER_CORE_FIELDS : app_log.warning("== UserClass / user_field : %s", user_field) self.__dict__[user_field] = "" app_log.warning("== UserClass / fields from **kwargs ...") for k, v in kwargs.items(): # print "{} : {}".format(k,v) app_log.warning("== UserClass / %s : %s ...", k, v) try : self.__dict__[k] = v except : pass print ### TO DO : hash password
Example #6
Source File: web.py From tornado-zh with MIT License | 6 votes |
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)
Example #7
Source File: web.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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)
Example #8
Source File: web.py From viewfinder with Apache License 2.0 | 6 votes |
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)
Example #9
Source File: web.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def log_exception(self, typ, value, tb): """Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1 """ if isinstance(value, HTTPError): if value.log_message: format = "%d %s: " + value.log_message args = ([value.status_code, self._request_summary()] + list(value.args)) gen_log.warning(format, *args) else: app_log.error("Uncaught exception %s\n%r", self._request_summary(), self.request, exc_info=(typ, value, tb))
Example #10
Source File: web.py From viewfinder with Apache License 2.0 | 6 votes |
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)
Example #11
Source File: web.py From viewfinder with Apache License 2.0 | 6 votes |
def log_exception(self, typ, value, tb): """Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1 """ if isinstance(value, HTTPError): if value.log_message: format = "%d %s: " + value.log_message args = ([value.status_code, self._request_summary()] + list(value.args)) gen_log.warning(format, *args) else: app_log.error("Uncaught exception %s\n%r", self._request_summary(), self.request, exc_info=(typ, value, tb))
Example #12
Source File: build.py From binderhub with BSD 3-Clause "New" or "Revised" License | 5 votes |
def stream_logs(self): import time time.sleep(3) for phase in ('Pending', 'Running', 'Succeed', 'Building'): if self.stop_event.is_set(): app_log.warning("Stopping logs of %s", self.name) return self.progress('log', json.dumps({ 'phase': phase, 'message': f"{phase}...\n", }) ) for i in range(5): if self.stop_event.is_set(): app_log.warning("Stopping logs of %s", self.name) return time.sleep(1) self.progress('log', json.dumps({ 'phase': 'unknown', 'message': f"Step {i+1}/10\n", }) ) self.progress('pod.phasechange', 'Succeeded') self.progress('log', json.dumps({ 'phase': 'Deleted', 'message': f"Deleted...\n", }) )
Example #13
Source File: main.py From OpenScraper with MIT License | 5 votes |
def create_datamodel_fields( logger, coll_model, fields_list, field_class ) : """ create datamodel fields from list of field basic dict like DATAMODEL_CORE_FIELDS """ timestamp = time.time() if field_class == "core": is_visible = False if field_class == "custom": is_visible = True ### instantiate db.datamodel with core fields (for internal use) fields_ = [ { "field_name" : field["field_name"], "field_type" : field["field_type"], "field_open" : field["field_open"], "field_class" : field_class , "added_by" : "admin", "added_at" : timestamp, "is_visible" : is_visible } for field in fields_list ] logger.warning("... create_datamodel_fields / datamodel - fields_ : ") # upsert fields as bulk job in mongoDB # cf : https://stackoverflow.com/questions/5292370/fast-or-bulk-upsert-in-pymongo operations =[ UpdateOne( {"field_name" : field["field_name"]}, {'$set': { k : v for k,v in field.iteritems() if k != "field_name" } }, upsert=True # do not upsert otherwise if yo don't want new fields to be created ) for field in fields_ ] coll_model.bulk_write(operations)
Example #14
Source File: controller.py From OpenScraper with MIT License | 5 votes |
def get(self): self.site_section = "404" # self.error_msg = "404 - page not found" print app_log.info("PageNotFoundHandler.post / uri : %s ", pformat(self.request.uri ) ) # pprint.pprint (self.request.uri ) app_log.info("PageNotFoundHandler.post / self.is_user_connected : %s ", pformat(self.is_user_connected ) ) # print self.is_user_connected app_log.warning("PageNotFoundHandler.post / request : \n %s ", pformat(self.request ) ) # pprint.pprint (self.request ) app_log.info("PageNotFoundHandler.post / request.arguments : \n %s ", pformat(self.request.arguments ) ) # pprint.pprint( self.request.arguments ) self.set_status(404) self.render("404.html", page_title = app_main_texts["main_title"], app_host = self.request.host, site_section = self.site_section, error_msg = self.error_msg, user = self.current_user, is_user_connected = self.is_user_connected, user_email = self.user_email, user_auth_level = self.user_auth_level, user_auth_level_dict = self.user_auth_level_dict ) ### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### ### INDEX PAGE ############################################################################## ### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ###
Example #15
Source File: builder.py From binderhub with BSD 3-Clause "New" or "Revised" License | 5 votes |
def emit(self, data): """Emit an eventstream event""" if type(data) is not str: serialized_data = json.dumps(data) else: serialized_data = data try: self.write('data: {}\n\n'.format(serialized_data)) await self.flush() except StreamClosedError: app_log.warning("Stream closed while handling %s", self.request.uri) # raise Finish to halt the handler raise Finish()
Example #16
Source File: web_test.py From pySINDy with MIT License | 5 votes |
def log_exception(self, typ, value, tb): if isinstance(value, PermissionError): app_log.warning('custom logging for PermissionError: %s', value.args[0]) else: RequestHandler.log_exception(self, typ, value, tb)
Example #17
Source File: routing.py From pySINDy with MIT License | 5 votes |
def process_rule(self, rule): rule = super(ReversibleRuleRouter, self).process_rule(rule) if rule.name: if rule.name in self.named_rules: app_log.warning( "Multiple handlers named %s; replacing previous value", rule.name) self.named_rules[rule.name] = rule return rule
Example #18
Source File: routing.py From teleport with Apache License 2.0 | 5 votes |
def process_rule(self, rule: "Rule") -> "Rule": rule = super(ReversibleRuleRouter, self).process_rule(rule) if rule.name: if rule.name in self.named_rules: app_log.warning( "Multiple handlers named %s; replacing previous value", rule.name ) self.named_rules[rule.name] = rule return rule
Example #19
Source File: controller.py From OpenScraper with MIT License | 5 votes |
def post(self): print app_log.info("ContributorDeleteHandler.post ... " ) app_log.info("ContributorDeleteHandler.post / request.arguments : \n %s ", pformat(self.request.arguments ) ) # TO DO : form validation ### get reset choice + data validation spider_id = self.get_argument("spider_id") app_log.info("ContributorDeleteHandler.post / spider_id : %s", spider_id ) spider_oid = ObjectId(spider_id) is_delete = self.get_argument("is_delete") app_log.info("ContributorDeleteHandler.post / is_delete : %s", is_delete ) # reset collection here if is_delete == "true" : app_log.warning("ContributorDeleteHandler.post / DELETING SPIDER FOR spider_id : %s", spider_id ) self.application.coll_spiders.delete_one({ "_id" : spider_oid }) self.error_msg = self.add_error_message_to_slug( error_string = "the spider was erased", args_to_delete = QUERY_SPIDER_BY_DEFAULT.keys() ) self.redirect("/contributors" + self.error_msg ) else : self.redirect("/contributors")
Example #20
Source File: web.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def add_handlers(self, host_pattern, host_handlers): """Appends the given handlers to our handler list. Host patterns are processed sequentially in the order they were added. All matching patterns will be considered. """ if not host_pattern.endswith("$"): host_pattern += "$" handlers = [] # The handlers with the wildcard host_pattern are a special # case - they're added in the constructor but should have lower # precedence than the more-precise handlers added later. # If a wildcard handler group exists, it should always be last # in the list, so insert new groups just before it. if self.handlers and self.handlers[-1][0].pattern == '.*$': self.handlers.insert(-1, (re.compile(host_pattern), handlers)) else: self.handlers.append((re.compile(host_pattern), handlers)) for spec in host_handlers: if isinstance(spec, (tuple, list)): assert len(spec) in (2, 3, 4) spec = URLSpec(*spec) handlers.append(spec) if spec.name: if spec.name in self.named_handlers: app_log.warning( "Multiple handlers named %s; replacing previous value", spec.name) self.named_handlers[spec.name] = spec
Example #21
Source File: web.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def _decode_signed_value_v1(secret, name, value, max_age_days, clock): parts = utf8(value).split(b"|") if len(parts) != 3: return None signature = _create_signature_v1(secret, name, parts[0], parts[1]) if not _time_independent_equals(parts[2], signature): gen_log.warning("Invalid cookie signature %r", value) return None timestamp = int(parts[1]) if timestamp < clock() - max_age_days * 86400: gen_log.warning("Expired cookie %r", value) return None if timestamp > clock() + 31 * 86400: # _cookie_signature does not hash a delimiter between the # parts of the cookie, so an attacker could transfer trailing # digits from the payload to the timestamp without altering the # signature. For backwards compatibility, sanity-check timestamp # here instead of modifying _cookie_signature. gen_log.warning("Cookie timestamp in future; possible tampering %r", value) return None if parts[1].startswith(b"0"): gen_log.warning("Tampered cookie %r", value) return None try: return base64.b64decode(parts[0]) except Exception: return None
Example #22
Source File: web_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def log_exception(self, typ, value, tb): if isinstance(value, PermissionError): app_log.warning('custom logging for PermissionError: %s', value.args[0]) else: RequestHandler.log_exception(self, typ, value, tb)
Example #23
Source File: routing.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
def process_rule(self, rule: "Rule") -> "Rule": rule = super(ReversibleRuleRouter, self).process_rule(rule) if rule.name: if rule.name in self.named_rules: app_log.warning( "Multiple handlers named %s; replacing previous value", rule.name ) self.named_rules[rule.name] = rule return rule
Example #24
Source File: web_test.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
def log_exception(self, typ, value, tb): if isinstance(value, PermissionError): app_log.warning("custom logging for PermissionError: %s", value.args[0]) else: RequestHandler.log_exception(self, typ, value, tb)
Example #25
Source File: routing.py From teleport with Apache License 2.0 | 5 votes |
def process_rule(self, rule: "Rule") -> "Rule": rule = super(ReversibleRuleRouter, self).process_rule(rule) if rule.name: if rule.name in self.named_rules: app_log.warning( "Multiple handlers named %s; replacing previous value", rule.name ) self.named_rules[rule.name] = rule return rule
Example #26
Source File: web.py From tornado-zh with MIT License | 5 votes |
def add_handlers(self, host_pattern, host_handlers): """添加给定的handler到我们的handler表. Host 模式将按照它们的添加顺序进行处理. 所有匹配模式将被考虑. """ if not host_pattern.endswith("$"): host_pattern += "$" handlers = [] # The handlers with the wildcard host_pattern are a special # case - they're added in the constructor but should have lower # precedence than the more-precise handlers added later. # If a wildcard handler group exists, it should always be last # in the list, so insert new groups just before it. if self.handlers and self.handlers[-1][0].pattern == '.*$': self.handlers.insert(-1, (re.compile(host_pattern), handlers)) else: self.handlers.append((re.compile(host_pattern), handlers)) for spec in host_handlers: if isinstance(spec, (tuple, list)): assert len(spec) in (2, 3, 4) spec = URLSpec(*spec) handlers.append(spec) if spec.name: if spec.name in self.named_handlers: app_log.warning( "Multiple handlers named %s; replacing previous value", spec.name) self.named_handlers[spec.name] = spec
Example #27
Source File: web.py From tornado-zh with MIT License | 5 votes |
def _decode_signed_value_v1(secret, name, value, max_age_days, clock): parts = utf8(value).split(b"|") if len(parts) != 3: return None signature = _create_signature_v1(secret, name, parts[0], parts[1]) if not _time_independent_equals(parts[2], signature): gen_log.warning("Invalid cookie signature %r", value) return None timestamp = int(parts[1]) if timestamp < clock() - max_age_days * 86400: gen_log.warning("Expired cookie %r", value) return None if timestamp > clock() + 31 * 86400: # _cookie_signature does not hash a delimiter between the # parts of the cookie, so an attacker could transfer trailing # digits from the payload to the timestamp without altering the # signature. For backwards compatibility, sanity-check timestamp # here instead of modifying _cookie_signature. gen_log.warning("Cookie timestamp in future; possible tampering %r", value) return None if parts[1].startswith(b"0"): gen_log.warning("Tampered cookie %r", value) return None try: return base64.b64decode(parts[0]) except Exception: return None
Example #28
Source File: web_test.py From tornado-zh with MIT License | 5 votes |
def log_exception(self, typ, value, tb): if isinstance(value, PermissionError): app_log.warning('custom logging for PermissionError: %s', value.args[0]) else: RequestHandler.log_exception(self, typ, value, tb)
Example #29
Source File: web.py From tornado-zh with MIT License | 5 votes |
def add_handlers(self, host_pattern, host_handlers): """添加给定的handler到我们的handler表. Host 模式将按照它们的添加顺序进行处理. 所有匹配模式将被考虑. """ if not host_pattern.endswith("$"): host_pattern += "$" handlers = [] # The handlers with the wildcard host_pattern are a special # case - they're added in the constructor but should have lower # precedence than the more-precise handlers added later. # If a wildcard handler group exists, it should always be last # in the list, so insert new groups just before it. if self.handlers and self.handlers[-1][0].pattern == '.*$': self.handlers.insert(-1, (re.compile(host_pattern), handlers)) else: self.handlers.append((re.compile(host_pattern), handlers)) for spec in host_handlers: if isinstance(spec, (tuple, list)): assert len(spec) in (2, 3, 4) spec = URLSpec(*spec) handlers.append(spec) if spec.name: if spec.name in self.named_handlers: app_log.warning( "Multiple handlers named %s; replacing previous value", spec.name) self.named_handlers[spec.name] = spec
Example #30
Source File: web.py From tornado-zh with MIT License | 5 votes |
def _decode_signed_value_v1(secret, name, value, max_age_days, clock): parts = utf8(value).split(b"|") if len(parts) != 3: return None signature = _create_signature_v1(secret, name, parts[0], parts[1]) if not _time_independent_equals(parts[2], signature): gen_log.warning("Invalid cookie signature %r", value) return None timestamp = int(parts[1]) if timestamp < clock() - max_age_days * 86400: gen_log.warning("Expired cookie %r", value) return None if timestamp > clock() + 31 * 86400: # _cookie_signature does not hash a delimiter between the # parts of the cookie, so an attacker could transfer trailing # digits from the payload to the timestamp without altering the # signature. For backwards compatibility, sanity-check timestamp # here instead of modifying _cookie_signature. gen_log.warning("Cookie timestamp in future; possible tampering %r", value) return None if parts[1].startswith(b"0"): gen_log.warning("Tampered cookie %r", value) return None try: return base64.b64decode(parts[0]) except Exception: return None