def get_logs(self): try: handler = get_handler(get_logger(None), "memory") return str(handler.get_buffer(MAX_LOG_DISPLAYED)) except Exception as e: log.exception(e) return None
def _export_logs(self): logs = "" logger = get_logger(None) handler = get_handler(logger, "memory") log_buffer = handler.get_buffer(MAX_LOG_DISPLAYED) for record in log_buffer: logs = logs + handler.format(record) + "\n" return logs
def _get_logs(self, limit=MAX_LOG_DISPLAYED): logs = [] handler = get_handler(get_logger(None), "memory") log_buffer = handler.get_buffer(limit) for record in log_buffer: logs.append(self._export_log_record(record)) limit = limit - 1 if limit == 0: return logs return logs
def _export_logs(self): logs = u"" logger = get_logger(None) handler = get_handler(logger, "memory") log_buffer = handler.get_buffer(MAX_LOG_DISPLAYED) for record in log_buffer: try: log = handler.format(record).decode("utf-8", errors="replace") except UnicodeEncodeError: log = handler.format(record) logs = logs + log + u"\n" return logs
def _export_logs(): """ Export all lines from the memory logger. :return bytes: bytes needed by zipfile.writestr() """ logger = get_logger(None) handler = get_handler(logger, 'memory') log_buffer = handler.get_buffer(MAX_LOG_DISPLAYED) for record in log_buffer: line = handler.format(record) if not isinstance(line, bytes): line = line.encode('utf-8', errors='replace') yield line