diff options
author | Christian Pointner <equinox@anytun.org> | 2009-02-22 14:32:51 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-02-22 14:32:51 +0000 |
commit | 1501e7126a04f12363b3a03d19fe0e0bae91b598 (patch) | |
tree | ddb529e9168e6deced7dac6d6d1cf9f80ea09244 /src | |
parent | added -L|--log to command line parser (diff) |
added log target support to anytun-contorld and anytun-config
Diffstat (limited to 'src')
-rw-r--r-- | src/anytun-config.cpp | 14 | ||||
-rw-r--r-- | src/anytun-controld.cpp | 18 | ||||
-rw-r--r-- | src/options.cpp | 2 |
3 files changed, 26 insertions, 8 deletions
diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp index 07344c1..d5dedf9 100644 --- a/src/anytun-config.cpp +++ b/src/anytun-config.cpp @@ -89,21 +89,31 @@ int main(int argc, char* argv[]) int ret=0; try { - cLog.addTarget("stderr:4"); bool result = gOpt.parse(argc, argv); if(!result) { gOpt.printUsage(); exit(0); } + StringList targets = gOpt.getLogTargets(); + if(targets.empty()) { + cLog.addTarget("stderr:4"); + } + else { + StringList::const_iterator it; + for(it = targets.begin();it != targets.end(); ++it) + cLog.addTarget(*it); + } } catch(syntax_error& e) { std::cerr << e << std::endl; - cLog.msg(Log::PRIO_ERR) << "exitting after syntax error"; gOpt.printUsage(); exit(-1); } + gOpt.parse_post(); // print warnings + + ConnectionList cl; SyncQueue queue; diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp index 2c6c619..372b0bb 100644 --- a/src/anytun-controld.cpp +++ b/src/anytun-controld.cpp @@ -97,26 +97,34 @@ int main(int argc, char* argv[]) bool daemonized=false; try { - cLog.addTarget("syslog:7,anytun-controld,daemon"); - cLog.msg(Log::PRIO_NOTICE) << "anytun-controld started..."; - try { bool result = gOpt.parse(argc, argv); if(!result) { - cLog.msg(Log::PRIO_NOTICE) << "printing help text and exitting"; gOpt.printUsage(); exit(0); } + StringList targets = gOpt.getLogTargets(); + if(targets.empty()) { + cLog.addTarget("syslog:7,anytun-controld,daemon"); + } + else { + StringList::const_iterator it; + for(it = targets.begin();it != targets.end(); ++it) + cLog.addTarget(*it); + } } catch(syntax_error& e) { std::cerr << e << std::endl; - cLog.msg(Log::PRIO_NOTICE) << "exitting after syntax error"; gOpt.printUsage(); exit(-1); } + cLog.msg(Log::PRIO_NOTICE) << "anytun-controld started..."; + gOpt.parse_post(); // print warnings + + std::ifstream file( gOpt.getFileName().c_str() ); if( file.is_open() ) file.close(); diff --git a/src/options.cpp b/src/options.cpp index ca55856..6aa795a 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -453,7 +453,7 @@ void Options::printUsage() #endif std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl; - std::cout << " add a log target" << std::endl; + std::cout << " add a log target, can be invoked several times" << std::endl; #if defined(ANYCTR_OPTIONS) |