예제 #1
0
    def content(self):
        records = []
        for record in self.get_and_clear():
            msg = record.getMessage()
            if isinstance(msg, bytes):
                msg = msg.decode('utf-8', 'ignore')
            records.append({
                'message':
                msg,
                'time':
                datetime.datetime.fromtimestamp(record.created),
                'level':
                record.levelname,
                'file':
                format_fname(record.pathname),
                'file_long':
                record.pathname,
                'line':
                record.lineno,
            })

        records = reversed(records)
        return unicode_text(
            render(dict(records=records), tg.config['debugbar.engine'],
                   'tgext.debugbar.sections.templates.logging!html').split(
                       '\n', 1)[-1])
예제 #2
0
    def wrapped_controller(*args, **kw):
        profiler = profile.Profile()

        try:
            request.tgdb_call_start_time = time.time()
            result = profiler.runcall(controller, *args, **kw)
            request.tgdb_call_time = (
                time.time() - request.tgdb_call_start_time) * 1000
        except:
            raise
        finally:
            stats = pstats.Stats(profiler)
            function_calls = []
            flist = stats.sort_stats('cumulative').fcn_list
            for func in flist:
                current = {}
                info = stats.stats[func]

                # Number of calls
                if info[0] != info[1]:
                    current['ncalls'] = '%d/%d' % (info[1], info[0])
                else:
                    current['ncalls'] = info[1]

                # Total time
                current['tottime'] = info[2] * 1000

                # Quotient of total time divided by number of calls
                if info[1]:
                    current['percall'] = info[2] * 1000 / info[1]
                else:
                    current['percall'] = 0

                # Cumulative time
                current['cumtime'] = info[3] * 1000

                # Quotient of the cumulative time divded by the number
                # of primitive calls.
                if info[0]:
                    current['percall_cum'] = info[3] * 1000 / info[0]
                else:
                    current['percall_cum'] = 0

                # Filename
                filename = pstats.func_std_string(func)
                current['filename_long'] = filename
                current['filename'] = format_fname(filename)
                function_calls.append(current)

            request.tgdb_profiling_stats = stats
            request.tgdb_profiling_function_calls = function_calls

        return result
예제 #3
0
    def wrapped_controller(*args, **kw):
        profiler = profile.Profile()

        try:
            request.tgdb_call_start_time = time.time()
            result = profiler.runcall(controller, *args, **kw)
            request.tgdb_call_time = (
                time.time() - request.tgdb_call_start_time) * 1000
        except:
            raise
        finally:
            stats = pstats.Stats(profiler)
            function_calls = []
            flist = stats.sort_stats('cumulative').fcn_list
            for func in flist:
                current = {}
                info = stats.stats[func]

                # Number of calls
                if info[0] != info[1]:
                    current['ncalls'] = '%d/%d' % (info[1], info[0])
                else:
                    current['ncalls'] = info[1]

                # Total time
                current['tottime'] = info[2] * 1000

                # Quotient of total time divided by number of calls
                if info[1]:
                    current['percall'] = info[2] * 1000 / info[1]
                else:
                    current['percall'] = 0

                # Cumulative time
                current['cumtime'] = info[3] * 1000

                # Quotient of the cumulative time divded by the number
                # of primitive calls.
                if info[0]:
                    current['percall_cum'] = info[3] * 1000 / info[0]
                else:
                    current['percall_cum'] = 0

                # Filename
                filename = pstats.func_std_string(func)
                current['filename_long'] = filename
                current['filename'] = format_fname(filename)
                function_calls.append(current)

            request.tgdb_profiling_stats = stats
            request.tgdb_profiling_function_calls = function_calls

        return result
예제 #4
0
    def content(self):
        records = []
        for record in self.get_and_clear():
            records.append({
                'message': record.getMessage().decode('utf-8', 'ignore'),
                'time': datetime.datetime.fromtimestamp(record.created),
                'level': record.levelname,
                'file': format_fname(record.pathname),
                'file_long': record.pathname,
                'line': record.lineno,
            })

        records = reversed(records)
        return unicode(render(
            dict(records=records),
            'genshi', 'tgext.debugbar.sections.templates.logging'
            ).split('\n', 1)[-1])
예제 #5
0
    def content(self):
        records = []
        for record in self.get_and_clear():
            msg = record.getMessage()
            if isinstance(msg, bytes):
                msg = msg.decode('utf-8', 'ignore')
            records.append({
                'message': msg,
                'time': datetime.datetime.fromtimestamp(record.created),
                'level': record.levelname,
                'file': format_fname(record.pathname),
                'file_long': record.pathname,
                'line': record.lineno,
            })

        records = reversed(records)
        return unicode_text(render(
            dict(records=records),
            tg.config['debugbar.engine'], 'tgext.debugbar.sections.templates.logging!html'
            ).split('\n', 1)[-1])