示例#1
0
void cdb_print(cdb_t *cdb) {

    const char *date_format = "%Y-%m-%d %H:%M:%S";
    cdb_request_t request;

    request.start  = 0;
    request.end    = 0;
    request.count  = 0;
    request.step   = 0;
    request.cooked = false;

    printf("============== Header ================\n");

    if (cdb_read_header(cdb) == CDB_SUCCESS) {
        cdb_print_header(cdb);
    }

    if (cdb->header->type == CDB_TYPE_COUNTER) {

        printf("============= Raw Counter Records =============\n");
        cdb_print_records(cdb, &request, stdout, date_format);
        printf("============== End Raw Counter Records ==============\n");

        printf("============== Cooked Records ================\n");

    } else {
        printf("============== Records ================\n");
    }

    request.cooked = true;
    cdb_print_records(cdb, &request, stdout, date_format);

    printf("============== End ================\n");
}
示例#2
0
static PyObject* cdb_py_print_records(PyObject *self, PyObject *args, PyObject *kwdict) {
  static char *kwlist[] = {
    "start", "end", "count", "cooked", "step", "file_obj", "date_format", NULL,
  };

  cdb_time_t start = 0;
  cdb_time_t end   = 0;
  int cooked       = 1;
  long step        = 0;
  int64_t count    = 0;
  cdb_t *cdb;
  PyObject *file_obj, *date_format;

  if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|LLLOzil:print_records", kwlist, &start, &end, &count, &file_obj, &date_format, &cooked, &step)) {
    return NULL;
  }

  cdb_request_t request = _parse_cdb_request(start, end, count, cooked, step);

  if (Py_None == date_format) {
    date_format = PyString_FromString("");
  }

  if (Py_None == file_obj || !PyFile_Check(file_obj)) {
    file_obj = PyString_FromString("stderr");
  }

  cdb = ((StorageObject*)self)->cdb;

  cdb_print_records(cdb, &request, PyFile_AsFile(file_obj), PyString_AsString(date_format));

  return self;
}