def log_traceback(traceback): """print traceback information with the log style. """ str_list = traceback.split("\n") for string in str_list: logger.warning(string)
def make_links(traceback): """ Make links using the given traceback """ lwords = traceback.split('"') # Making the short circuit compatible with <= python2.4 result = (len(lwords) != 0) and lwords[0] or '' i = 1 while i < len(lwords): link = make_link(lwords[i]) if link == '': result += '"' + lwords[i] else: result += link if i + 1 < len(lwords): result += lwords[i + 1] i = i + 1 i = i + 1 return result
def make_links(traceback): """ Make links using the given traceback """ lwords = traceback.split('"') # Making the short circuit compatible with <= python2.4 result = (len(lwords) != 0) and lwords[0] or '' i = 1 while i < len(lwords): link = make_link(lwords[i]) if link == '': result += '"' + lwords[i] else: result += link if i + 1 < len(lwords): result += lwords[i + 1] i = i + 1 i = i + 1 return result
def log(self, request, response, configuration): # collect details from request, response, and exception traceback (if any) http_details = '{} {} {} {}'.format( utils.When.timestamp(), response.status_code, request.http.method.ljust(7), '/{}'.format(request.url.path), ) # no error if response.status_code < 400: self.logger.info(http_details) # client error elif response.status_code < 500: self.logger.warning(http_details) # server error else: traceback = getattr(response, 'traceback', '') formatted_traceback = ' ' + ('\n ').join( traceback.split('\n')) formatted_traceback = '\n'.join([ line for line in formatted_traceback.splitlines() if line.strip() ]) specifier = '{}\n\n{}\n' exception_details = specifier.format(http_details, formatted_traceback) self.logger.error(exception_details)
def printStacktrace(traceback): printLog("\n\n") funcnames = traceback.split('\n') for func in funcnames: if (gLogger): printLog(func) else: print func
def create_pdf(traceback): traceback = traceback.split("\n") pdf = FPDF() pdf.add_page() pdf.set_font('Arial', 'B', 12) pdf.cell(40, 10, "Send this error report to the administrator if the problem occurs again: \n", 0, 1) for x in xrange(0, len(traceback)): pdf.cell(40, 10, traceback[x], 0, 1) print traceback[x] pdf.output('pdf/stack.pdf', 'F')
def log(self, request, response, configuration): # collect details from request, response, and exception traceback (if any) http_details = '{} {} {} {}'.format( utils.When.timestamp(), response.status_code, request.http.method.ljust(7), '/{}'.format(request.url.path), ) # no error if response.status_code < 400: self.logger.info(http_details) # client error elif response.status_code < 500: self.logger.warning(http_details) # server error else: traceback = getattr(response, 'traceback', '') formatted_traceback = ' ' + ('\n ').join(traceback.split('\n')) formatted_traceback = '\n'.join( [line for line in formatted_traceback.splitlines() if line.strip()] ) specifier = '{}\n\n{}\n' exception_details = specifier.format(http_details, formatted_traceback) self.logger.error(exception_details)
def log_traceback(traceback): str_list=traceback.split("\n") for string in str_list: logger.warning(string)