示例#1
0
def logs_full():
    return render_template(
        "admin/logs.html",
        logs=logger.get_log_dicts(),
        log_view_n_lines="all",
        in_admin=True
    )
def logs(limit=None):
    if limit is None:
        last_n_lines_to_pass = config.log_view_n_lines
    else:
        last_n_lines_to_pass = limit
    return render_template(
        "admin/logs.html",
        logs=logger.get_log_dicts(last_n_lines=last_n_lines_to_pass),
        log_view_n_lines=last_n_lines_to_pass,
        in_admin=True)
示例#3
0
def logs(limit=None):
    if limit is None:
        last_n_lines_to_pass = config.log_view_n_lines
    else:
        last_n_lines_to_pass = limit
    return render_template(
        "admin/logs.html",
        logs=logger.get_log_dicts(last_n_lines=last_n_lines_to_pass),
        log_view_n_lines=last_n_lines_to_pass,
        in_admin=True
    )
示例#4
0
def draw_custom_graph(user_agents):
    plot_x_y = []

    # requests = log_parser.get_log_dicts(user_agent = r'SiteSucker.*')
    for user_agent in user_agents:
        requests = logger.get_log_dicts(user_agent=user_agent)
        first_date = None
        x = []
        y = []
        for index, request in enumerate(requests):
            if index is not 0:
                x.append(time_delta(request['datetime'], first_date))
            else:
                first_date = request['datetime']
                x.append(0)
            y.append(index)
        plot_x_y.append({
            'x': x,
            'y': y
        })

    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)

    current_index = 0
    for xy in plot_x_y:
        # todo: Use different color (not only random) and add the ability to choose multiple user_agent.
        ax.plot(
            xy['x'], xy['y'],
            color=graph_colors[current_index % len(graph_colors)],
            label=user_agents[current_index]
        )
        ax.legend(framealpha=0.5, loc=4, prop={'size': 8})
        current_index += 1

    plt.xlabel('Delta Time (seconds)')
    plt.ylabel('Number of requests')

    ax.xaxis.set_major_formatter(formatter)

    output = StringIO.StringIO()
    canvas = FigureCanvas(fig)
    canvas.print_svg(output)
    return output
def logs_full():
    return render_template("admin/logs.html",
                           logs=logger.get_log_dicts(),
                           log_view_n_lines="all",
                           in_admin=True)