X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Ftools%2Fgsprintconsole.c;h=fbd67e377fac9556c695af0d1d3656b182fc985e;hb=3ff5c433efcaee8b01fbeed90ab848008f2e6278;hp=4b18ab56862d2c441d6c68c59c656edc2c8b09d8;hpb=c9783d8ea8b85d810483559e50dbf2297109e349;p=com%2Fgs-lite.git diff --git a/src/tools/gsprintconsole.c b/src/tools/gsprintconsole.c index 4b18ab5..fbd67e3 100644 --- a/src/tools/gsprintconsole.c +++ b/src/tools/gsprintconsole.c @@ -38,6 +38,7 @@ static char linebuf[MAXLINE]; int listensockfd=0; int fd=0; +FILE* outf; // Not all systems have timersub defined so make sure its ther #ifndef timersub @@ -123,7 +124,7 @@ static void emit_socket() { static void emit_line() { if (tcpport==0) { - printf("%s",linebuf); + fprintf(outf,"%s",linebuf); } else { emit_socket(); } @@ -161,9 +162,11 @@ int main(int argc, char* argv[]) { time_t start_time, curr_time; gsopenlog(argv[0]); + + // by default the output will go to stdout + outf = stdout; - - while ((ch = getopt(argc, argv, "l:p:r:vXD")) != -1) { + while ((ch = getopt(argc, argv, "l:p:r:veXD")) != -1) { switch (ch) { case 'r': bufsz=atoi(optarg); @@ -174,6 +177,9 @@ int main(int argc, char* argv[]) { case 'v': verbose++; break; + case 'e': + outf = stderr; + break; case 'X': xit++; break; @@ -185,7 +191,7 @@ int main(int argc, char* argv[]) { break; default: usage: - fprintf(stderr, "usage: %s [-r ] [-p ] [-l ] [-v] [-X] [-D] : query param1 param2...\n", + fprintf(stderr, "usage: %s [-r ] [-e] [-p ] [-l ] [-v] [-X] [-D] : query param1 param2...\n", *argv); exit(1); }