Exemplo n.º 1
0
/* Entry point to generate a a json report writing it to the fp */
void
output_json (GLog * logger, GHolder * holder)
{
  FILE *fp = stdout;
  GModule module;

  GPercTotals totals = {
    .hits = logger->valid,
    .visitors = ht_get_size_uniqmap (VISITORS),
    .bw = logger->resp_size,
  };

  /* use new lines to prettify output */
  if (conf.json_pretty_print)
    nlines = 1;

  pjson (fp, "{%.*s", nlines, NL);
  print_json_summary (fp, logger);

  for (module = 0; module < TOTAL_MODULES; module++) {
    const GPanel *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;

    panel->render (fp, holder + module, totals, panel);
    pjson (fp, (module != TOTAL_MODULES - 1) ? ",%.*s" : "%.*s", nlines, NL);
  }
  pjson (fp, "}");

  fclose (fp);
}
Exemplo n.º 2
0
Arquivo: csv.c Projeto: 0-T-0/goaccess
/* Entry point to generate a a csv report writing it to the fp */
void
output_csv (GLog * logger, GHolder * holder)
{
  GModule module;
  FILE *fp = stdout;

  GPercTotals totals = {
    .hits = logger->valid,
    .visitors = ht_get_size_uniqmap (VISITORS),
    .bw = logger->resp_size,
  };

  if (!conf.no_csv_summary)
    print_csv_summary (fp, logger);

  for (module = 0; module < TOTAL_MODULES; module++) {
    const GPanel *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;
    panel->render (fp, holder + module, totals);
  }

  fclose (fp);
}
Exemplo n.º 3
0
/* Entry point to generate a a csv report writing it to the fp */
void
output_csv (GLog * logger, GHolder * holder)
{
    GModule module;
    FILE *fp = stdout;
    const GPanel *panel = NULL;
    size_t idx = 0;

    if (!conf.no_csv_summary)
        print_csv_summary (fp, logger);

    FOREACH_MODULE (idx, module_list) {
        module = module_list[idx];

        if (!(panel = panel_lookup (module)))
            continue;
        panel->render (fp, holder + module, logger->valid);
    }
Exemplo n.º 4
0
/* Entry point to generate a a csv report writing it to the fp */
void
output_csv (GLog * logger, GHolder * holder)
{
  GModule module;
  FILE *fp = stdout;

  if (!conf.no_csv_summary)
    print_csv_summary (fp, logger);

  for (module = 0; module < TOTAL_MODULES; module++) {
    const GPanel *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;
    panel->render (fp, holder + module, logger->valid);
  }

  fclose (fp);
}
Exemplo n.º 5
0
/* follow the JSON style similar to http://developer.github.com/v3/ */
void
output_json (GLog * logger, GHolder * holder)
{
  GModule module;
  FILE *fp = stdout;

  fprintf (fp, "{\n");
  print_json_summary (fp, logger);
  for (module = 0; module < TOTAL_MODULES; module++) {
    const GJSON *panel = panel_lookup (module);
    if (!panel)
      continue;
    if (ignore_panel (module))
      continue;
    panel->render (fp, holder + module, logger->process);
    module != TOTAL_MODULES - 1 ? fprintf (fp, ",\n") : fprintf (fp, "\n");
  }
  fprintf (fp, "}");

  fclose (fp);
}
Exemplo n.º 6
0
/* Load raw data into our holder structure */
void
load_holder_data (GRawData * raw_data, GHolder * h, GModule module, GSort sort)
{
  int i, size = 0;
  const GPanel *panel = panel_lookup (module);

  size = raw_data->size;
  h->holder_size = size > MAX_CHOICES ? MAX_CHOICES : size;
  h->ht_size = size;
  h->idx = 0;
  h->module = module;
  h->sub_items_size = 0;
  h->items = new_gholder_item (h->holder_size);

  for (i = 0; i < h->holder_size; i++) {
    panel->insert (raw_data->items[i], h, panel);
  }
  sort_holder_items (h->items, h->idx, sort);
  if (h->sub_items_size)
    sort_sub_list (h, sort);
  free_raw_data (raw_data);
}
Exemplo n.º 7
0
/* Iterate over all panels and generate json output. */
static GJSON *
init_json_output (GLog * glog, GHolder * holder)
{
  GJSON *json = NULL;
  GModule module;
  GPercTotals totals;
  const GPanel *panel = NULL;
  size_t idx = 0, npanels = num_panels (), cnt = 0;

  json = new_gjson ();

  popen_obj (json, 0);
  print_json_summary (json, glog, holder);

  FOREACH_MODULE (idx, module_list) {
    module = module_list[idx];

    if (!(panel = panel_lookup (module)))
      continue;

    set_module_totals (module, &totals);
    panel->render (json, holder + module, totals, panel);
    pjson (json, (cnt++ != npanels - 1) ? ",%.*s" : "%.*s", nlines, NL);
  }