Changeset: 1f17463b7cd0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1f17463b7cd0
Modified Files:
clients/mapiclient/stethoscope.c
monetdb5/mal/mal_profiler.c
Branch: default
Log Message:
Add a pretty print argument to stethoscope
When running stethoscope with the flag -j produces raw JSON objects, ie. one
object per line. Adding the -y flag, produces pretty printed JSON output.
Running with neither will produce the legacy, line oriented format.
diffs (112 lines):
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -72,6 +72,7 @@ static char hostname[128];
static char *filename = NULL;
static int beat = 0;
static int json = 0;
+static int stream_mode = 1;
static Mapi dbh;
static MapiHdl hdl = NULL;
static FILE *trace = NULL;
@@ -201,11 +202,12 @@ usageStethoscope(void)
fprintf(stderr, " -h | --host=<hostname>\n");
fprintf(stderr, " -c | --convert=<old formated file>\n");
fprintf(stderr, " -j | --json\n");
+ fprintf(stderr, " -y | --pretty (implies --json)\n");
fprintf(stderr, " -o | --output=<file>\n");
- fprintf(stderr, " -b | --beat=<delay> in milliseconds (default 50)\n");
- fprintf(stderr, " -D | --debug\n");
+ fprintf(stderr, " -b | --beat=<delay> in milliseconds (default 50)\n");
+ fprintf(stderr, " -D | --debug\n");
fprintf(stderr, " -? | --help\n");
- exit(-1);
+ exit(-1);
}
/* Any signal should be captured and turned into a graceful
@@ -242,7 +244,7 @@ main(int argc, char **argv)
int done = 0;
EventRecord *ev = malloc(sizeof(EventRecord));
- static struct option long_options[12] = {
+ static struct option long_options[13] = {
{ "dbname", 1, 0, 'd' },
{ "user", 1, 0, 'u' },
{ "port", 1, 0, 'p' },
@@ -251,6 +253,7 @@ main(int argc, char **argv)
{ "help", 0, 0, '?' },
{ "convert", 1, 0, 'c'},
{ "json", 0, 0, 'j'},
+ { "pretty", 0, 0, 'y'},
{ "output", 1, 0, 'o' },
{ "debug", 0, 0, 'D' },
{ "beat", 1, 0, 'b' },
@@ -268,7 +271,7 @@ main(int argc, char **argv)
while (1) {
int option_index = 0;
- int c = getopt_long(argc, argv, "d:u:p:P:h:?jo:Db:",
+ int c = getopt_long(argc, argv, "d:u:p:P:h:?jyo:Db:",
long_options, &option_index);
if (c == -1)
break;
@@ -310,6 +313,11 @@ main(int argc, char **argv)
break;
case 'j':
json = 1;
+ stream_mode = 3;
+ break;
+ case 'y':
+ stream_mode = 1;
+ json = 1;
break;
case 'o':
filename = strdup(optarg);
@@ -326,6 +334,7 @@ main(int argc, char **argv)
exit(-1);
}
}
+
if( conversion){
convertOldFormat(conversion);
return 0;
@@ -384,7 +393,7 @@ main(int argc, char **argv)
fprintf(stderr,"-- %s\n",buf);
doQ(buf);
- snprintf(buf, BUFSIZ, " profiler.openstream(1);");
+ snprintf(buf, BUFSIZ, " profiler.openstream(%d);", stream_mode);
if( debug)
fprintf(stderr,"--%s\n",buf);
doQ(buf);
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -314,7 +314,7 @@ This information can be used to determin
GDKfree(tname);
logadd("}%s%s", (j< pci->argc-1 && j !=
pci->retc -1?",":""), pret);
}
- logadd("] %s",prettify); // end marker for arguments
+ logadd("]%s",prettify); // end marker for arguments
}
}
#endif
@@ -434,7 +434,7 @@ profilerEvent(MalBlkPtr mb, MalStkPtr st
if( sqlProfiling && !start )
cachedProfilerEvent(mb, stk, pci);
-
+
if( eventstream) {
renderProfilerEvent(mb, stk, pci, start, usrname);
if ( start && pci->pc ==0)
@@ -471,7 +471,7 @@ openProfilerStream(stream *fd, int mode)
closeProfilerStream();
malProfileMode = -1;
eventstream = fd;
- prettify = (mode & PROFSINGLELINE) ? " ": "\n";
+ prettify = (mode & PROFSINGLELINE) ? "": "\n";
/* show all in progress instructions for stethoscope startup */
if( (mode & PROFSHOWRUNNING) > 0){
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list