From f626d742ccf36a286de02cfb6b675460f5edcd39 Mon Sep 17 00:00:00 2001 From: Eugine Blikh <bigbes@gmail.com> Date: Fri, 4 Oct 2013 19:39:39 +0400 Subject: [PATCH] removing unnecesary quotes from output, add cookie, unify callbacks to use tnt_log_raw --- client/tarantool/tc_print.c | 4 ++-- client/tarantool/tc_print_snap.c | 12 ++++++------ client/tarantool/tc_print_snap.h | 2 +- client/tarantool/tc_print_xlog.c | 24 ++++++++++++++---------- client/tarantool/tc_print_xlog.h | 2 +- client/tarantool/tc_store.c | 4 ++-- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/client/tarantool/tc_print.c b/client/tarantool/tc_print.c index 512cb6b811..c512c35699 100644 --- a/client/tarantool/tc_print.c +++ b/client/tarantool/tc_print.c @@ -194,7 +194,6 @@ void tc_print_fields(struct tnt_tuple *tu) while (tnt_next(&ifl)) { if (TNT_IFIELD_IDX(&ifl) != 0) tc_printf(", "); - tc_printf("'"); char *data = TNT_IFIELD_DATA(&ifl); uint32_t size = TNT_IFIELD_SIZE(&ifl); switch (size) { @@ -205,9 +204,10 @@ void tc_print_fields(struct tnt_tuple *tu) tc_printf("%"PRIu64, *((uint64_t*)data)); break; default: + tc_printf("'"); tc_print_string(data, size, 0); + tc_printf("'"); } - tc_printf("'"); } if (ifl.status == TNT_ITER_FAIL) tc_printf("<parsing error>"); diff --git a/client/tarantool/tc_print_snap.c b/client/tarantool/tc_print_snap.c index 41dd902845..f16735cafe 100644 --- a/client/tarantool/tc_print_snap.c +++ b/client/tarantool/tc_print_snap.c @@ -20,30 +20,30 @@ extern struct tc tc; static void -tc_printer_snap_raw( struct tnt_log_row_snap_v11 *row, +tc_printer_snap_raw( struct tnt_log_row *row, struct tnt_tuple *tu) { if (tc.opt.raw_with_headers) { fwrite(&tnt_log_marker_v11, sizeof(tnt_log_marker_v11), 1, stdout); } - fwrite(row, sizeof(row), 1, stdout); + fwrite(&(row->row_snap), sizeof(row->row_snap), 1, stdout); fwrite(tu->data, tu->size, 1, stdout); } static void -tc_printer_snap_tarantool( struct tnt_log_row_snap_v11 *row, +tc_printer_snap_tarantool( struct tnt_log_row *row, struct tnt_tuple *tu) { tc_printf("space: %"PRIu32" ", - row->space); + row->row_snap.space); tc_print_tuple(tu); } static void -tc_printer_snap_lua( struct tnt_log_row_snap_v11 *row, +tc_printer_snap_lua( struct tnt_log_row *row, struct tnt_tuple *tu) { - tc_printf("lua box.insert(%"PRIu32", ", row->space); + tc_printf("lua box.insert(%"PRIu32", ", row->row_snap.space); tc_print_lua_fields(tu); tc_printf(")"); if (tc.opt.delim_len > 0) diff --git a/client/tarantool/tc_print_snap.h b/client/tarantool/tc_print_snap.h index 9bf467a2bc..2a661700cb 100644 --- a/client/tarantool/tc_print_snap.h +++ b/client/tarantool/tc_print_snap.h @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -typedef void (*tc_printerf_snap_t)(struct tnt_log_row_snap_v11 *row, +typedef void (*tc_printerf_snap_t)(struct tnt_log_row *row, struct tnt_tuple *tu); tc_printerf_snap_t tc_print_getsnapcb(const char *name); diff --git a/client/tarantool/tc_print_xlog.c b/client/tarantool/tc_print_xlog.c index 542f395285..601e1a876e 100644 --- a/client/tarantool/tc_print_xlog.c +++ b/client/tarantool/tc_print_xlog.c @@ -32,6 +32,7 @@ #include <stdio.h> #include <inttypes.h> #include <strings.h> +#include <arpa/inet.h> #include <connector/c/include/tarantool/tnt.h> #include <connector/c/include/tarantool/tnt_xlog.h> @@ -48,28 +49,31 @@ extern struct tc tc; static void -tc_printer_xlog_raw(struct tnt_log_header_v11 *hdr, +tc_printer_xlog_raw(struct tnt_log_row *row, struct tnt_request *r) { if (tc.opt.raw_with_headers) { fwrite(&tnt_log_marker_v11, sizeof(tnt_log_marker_v11), 1, stdout); } - fwrite(hdr, sizeof(*hdr), 1, stdout); + fwrite(&(row->hdr), sizeof(row->hdr), 1, stdout); fwrite(r->origin, r->origin_size, 1, stdout); } static void -tc_printer_xlog_tarantool(struct tnt_log_header_v11 *hdr, +tc_printer_xlog_tarantool(struct tnt_log_row *row, struct tnt_request *r) { + struct sockaddr_in *peer = (void *)&row->row.cookie; tc_printf("%s, lsn: %"PRIu64", time: %lf, len: %"PRIu32", space: " - "%"PRIu32" ", + "%"PRIu32", cookie: %s:%d ", tc_query_type(r->h.type), - hdr->lsn, - hdr->tm, - hdr->len, - r->r.insert.h.ns + row->hdr.lsn, + row->hdr.tm, + row->hdr.len, + r->r.insert.h.ns, + inet_ntoa(peer->sin_addr), + ntohs(peer->sin_port) ); switch (r->h.type) { case TNT_OP_INSERT: @@ -85,7 +89,7 @@ tc_printer_xlog_tarantool(struct tnt_log_header_v11 *hdr, } static void -tc_printer_xlog_lua(struct tnt_log_header_v11 *hdr, +tc_printer_xlog_lua(struct tnt_log_row *row, struct tnt_request *r) { tc_printf("lua box."); @@ -179,7 +183,7 @@ tc_printer_xlog_lua(struct tnt_log_header_v11 *hdr, } break; } - tc_printf(") -- %"PRIu64, hdr->lsn); + tc_printf(") -- %"PRIu64, row->hdr.lsn); if (tc.opt.delim_len > 0) tc_printf("%s\n", tc.opt.delim); else diff --git a/client/tarantool/tc_print_xlog.h b/client/tarantool/tc_print_xlog.h index e9918606ee..bc48fc9891 100644 --- a/client/tarantool/tc_print_xlog.h +++ b/client/tarantool/tc_print_xlog.h @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -typedef void (*tc_printerf_xlog_t)(struct tnt_log_header_v11 *hdr, +typedef void (*tc_printerf_xlog_t)(struct tnt_log_row *row, struct tnt_request *r); tc_printerf_xlog_t tc_print_getxlogcb(const char *name); diff --git a/client/tarantool/tc_store.c b/client/tarantool/tc_store.c index 0fbea373d5..17228fe2c7 100644 --- a/client/tarantool/tc_store.c +++ b/client/tarantool/tc_store.c @@ -130,7 +130,7 @@ static int tc_store_xlog_printer(struct tnt_iter *i) { return 0; struct tnt_stream_xlog *s = TNT_SXLOG_CAST(TNT_IREQUEST_STREAM(i)); - ((tc_printerf_xlog_t)tc.opt.xlog_printer)(&s->log.current.hdr, r); + ((tc_printerf_xlog_t)tc.opt.xlog_printer)(&s->log.current, r); return 0; } @@ -142,7 +142,7 @@ static int tc_store_snap_printer(struct tnt_iter *i) { if (ss->log.current.row_snap.space != tc.opt.space) return 0; } - ((tc_printerf_snap_t)tc.opt.snap_printer)(&ss->log.current.row_snap, tu); + ((tc_printerf_snap_t)tc.opt.snap_printer)(&ss->log.current, tu); return 0; } -- GitLab