6 #include "tclap/CmdLine.h"
8 #include <g3log/logworker.hpp>
12 int main(
int argc,
char* argv[])
16 string logPath(
"/tmp");
17 if (getenv(
"G3LOG_log_dir") !=
nullptr) {
18 logPath = *getenv(
"G3LOG_log_dir");
20 std::unique_ptr<g3::LogWorker> g3log{g3::LogWorker::createLogWorker()};
21 g3log->addDefaultLogger(argv[0], logPath);
22 g3::initializeLogging(g3log.get());
23 cout <<
"If you do not want log in /tmp, define environment "
24 <<
"variable G3LOG_log_dir e.g. with value ./ " << endl;
29 cout <<
"Process the objdriver output with \"cut -f 2 -d ] <logfile>\" to "
30 "get a reasonable output."
34 TCLAP::CmdLine cmd(
"Command description message",
' ',
"0.9");
35 TCLAP::ValueArg<string> nameArg(
"n",
"name",
"Name to print",
true,
"homer",
"string", cmd);
36 TCLAP::SwitchArg reverseSwitch(
"r",
"reverse",
"Print name backwards", cmd,
false);
39 cmd.parse(argc, static_cast<const char* const*>(argv));
40 std::string name(const_cast<const std::string&>(nameArg.getValue()));
41 bool reverseName = reverseSwitch.getValue();
45 reverse(name.begin(), name.end());
46 cout <<
"My name (spelled backwards) is: " << name << endl;
48 cout <<
"My name is: " << name << endl;
52 LOG(INFO) <<
"hello there: " << endl;
53 }
catch (TCLAP::ArgException& e) {
54 cerr <<
"error: " << e.error() <<
" for argument " << e.argId() << std::endl;
55 }
catch (exception& e) {
56 cerr << e.what() << endl;
58 cerr <<
"Unknown exception" << endl;
60 cout <<
"Done, exiting ..." << endl;
Comprehensive include file for all tracer classes.
int main(int argc, char *argv[])