def log(*args, **record): if args: record['type'] = args[0] if len(args) > 1: record['text'] = args[1] assert len(args) == 2 record.setdefault('type', 'unknown') for field in 'user', 'text': value = record.get(field) # if isinstance(value, str): record[field] = value.decode('utf-8', 'replace') level = record.get('severity') or INFO type = record.get('type', '') if pony_logger.level <= level and root_logger.level <= level and not type.startswith('logging:'): prefix = record.get('prefix', '') text = record.get('text', '') if type != 'exception': message = prefix + text else: message = record['traceback'] if text.startswith('SyntaxError: '): message = message.decode('utf-8', 'replace').encode('cp1251') message = restore_escapes(message) if message: pony_logger.log(level, message) if LOG_TO_SQLITE: record['timestamp'] = current_timestamp() record['process_id'] = process_id record['thread_id'] = local.thread_id record.setdefault('trans_id', None) queue.put(record) # record can be modified inside LoggerThread
def log(*args, **record): if args: record['type'] = args[0] if len(args) > 1: record['text'] = args[1] assert len(args) == 2 record.setdefault('type', 'unknown') for field in 'user', 'text': value = record.get(field) # if isinstance(value, str): record[field] = value.decode('utf-8', 'replace') level = record.get('severity') or INFO type = record.get('type', '') if pony_logger.level <= level and root_logger.level <= level and not type.startswith( 'logging:'): prefix = record.get('prefix', '') text = record.get('text', '') if type != 'exception': message = prefix + text else: message = record['traceback'] if text.startswith('SyntaxError: '): message = message.decode('utf-8', 'replace').encode('cp1251') message = restore_escapes(message) if message: pony_logger.log(level, message) if LOG_TO_SQLITE: record['timestamp'] = current_timestamp() record['process_id'] = process_id record['thread_id'] = local.thread_id record.setdefault('trans_id', None) queue.put(record) # record can be modified inside LoggerThread
def log(*args, **record): if args: record["type"] = args[0] if len(args) > 1: record["text"] = args[1] assert len(args) == 2 record.setdefault("type", "unknown") for field in "user", "text": value = record.get(field) # if isinstance(value, str): record[field] = value.decode('utf-8', 'replace') level = record.get("severity") or INFO type = record.get("type", "") if pony_logger.level <= level and root_logger.level <= level and not type.startswith("logging:"): prefix = record.get("prefix", "") text = record.get("text", "") if type != "exception": message = prefix + text else: message = record["traceback"] if text.startswith("SyntaxError: "): message = message.decode("utf-8", "replace").encode("cp1251") message = restore_escapes(message) if message: pony_logger.log(level, message) if LOG_TO_SQLITE: record["timestamp"] = current_timestamp() record["process_id"] = process_id record["thread_id"] = local.thread_id record.setdefault("trans_id", None) queue.put(record) # record can be modified inside LoggerThread
def restore_escapes(s): s = tostring(s) if not options.DEBUGGING_RESTORE_ESCAPES: return s return utils.restore_escapes(s, 'utf-8').decode('utf-8')