From 7c196ffde665a673e6e864754219b0e2c74001ac Mon Sep 17 00:00:00 2001 From: tycho Date: Mon, 18 May 2015 18:50:29 +0100 Subject: Move commlog arguments over to TCLAP --- src/main.cpp | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8a237b8ee..fdc3c7872 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -374,6 +374,12 @@ std::unique_ptr parseArguments(int argc, char **argv) TCLAP::MultiArg portsArg("p", "port", "The port number the server should listen to", false, "port", cmd); + TCLAP::SwitchArg commLogArg("", "log-comm", "Log server client communications to file", cmd); + + TCLAP::SwitchArg commLogInArg("", "log-comm-in", "Log inbound server client communications to file", cmd); + + TCLAP::SwitchArg commLogOutArg("", "log-comm-out", "Log outbound server client communications to file", cmd); + cmd.parse(argc, argv); auto repo = cpp14::make_unique(); @@ -396,6 +402,17 @@ std::unique_ptr parseArguments(int argc, char **argv) } } + if (commLogArg.getValue()) + { + g_ShouldLogCommIn = true; + g_ShouldLogCommOut = true; + } + else + { + g_ShouldLogCommIn = commLogInArg.getValue(); + g_ShouldLogCommOut = commLogOutArg.getValue(); + } + repo->SetReadOnly(); return repo; @@ -473,31 +490,7 @@ int main(int argc, char **argv) for (int i = 0; i < argc; i++) { AString Arg(argv[i]); - if ( - (NoCaseCompare(Arg, "/commlog") == 0) || - (NoCaseCompare(Arg, "/logcomm") == 0) - ) - { - g_ShouldLogCommIn = true; - g_ShouldLogCommOut = true; - } - else if ( - (NoCaseCompare(Arg, "/commlogin") == 0) || - (NoCaseCompare(Arg, "/comminlog") == 0) || - (NoCaseCompare(Arg, "/logcommin") == 0) - ) - { - g_ShouldLogCommIn = true; - } - else if ( - (NoCaseCompare(Arg, "/commlogout") == 0) || - (NoCaseCompare(Arg, "/commoutlog") == 0) || - (NoCaseCompare(Arg, "/logcommout") == 0) - ) - { - g_ShouldLogCommOut = true; - } - else if (NoCaseCompare(Arg, "nooutbuf") == 0) + if (NoCaseCompare(Arg, "nooutbuf") == 0) { setvbuf(stdout, nullptr, _IONBF, 0); } -- cgit v1.2.3 From d9d4adc2a590768de544dc9d694e0a6550f9dab5 Mon Sep 17 00:00:00 2001 From: tycho Date: Mon, 18 May 2015 18:57:16 +0100 Subject: Moved no buffering command line argument to tclap --- src/main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fdc3c7872..5cd057278 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -380,6 +380,8 @@ std::unique_ptr parseArguments(int argc, char **argv) TCLAP::SwitchArg commLogOutArg("", "log-comm-out", "Log outbound server client communications to file", cmd); + TCLAP::SwitchArg noBufArg("", "no-output-buffering", "Disable output buffering", cmd); + cmd.parse(argc, argv); auto repo = cpp14::make_unique(); @@ -413,6 +415,11 @@ std::unique_ptr parseArguments(int argc, char **argv) g_ShouldLogCommOut = commLogOutArg.getValue(); } + if (noBufArg.getValue()) + { + setvbuf(stdout, nullptr, _IONBF, 0); + } + repo->SetReadOnly(); return repo; @@ -490,11 +497,7 @@ int main(int argc, char **argv) for (int i = 0; i < argc; i++) { AString Arg(argv[i]); - if (NoCaseCompare(Arg, "nooutbuf") == 0) - { - setvbuf(stdout, nullptr, _IONBF, 0); - } - else if (NoCaseCompare(Arg, "/service") == 0) + if (NoCaseCompare(Arg, "/service") == 0) { cRoot::m_RunAsService = true; } -- cgit v1.2.3