From aa349f0ceef99c61160f578676f5f5b62b274a74 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 22 Feb 2009 14:20:46 +0000 Subject: added -L|--log to command line parser --- src/anytun.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/anytun.cpp') diff --git a/src/anytun.cpp b/src/anytun.cpp index b6f370b..fa1d186 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -362,33 +362,39 @@ int main(int argc, char* argv[]) { try { + bool result = gOpt.parse(argc, argv); + if(!result) { + gOpt.printUsage(); + exit(0); + } + StringList targets = gOpt.getLogTargets(); + if(targets.empty()) { #ifndef _MSC_VER - cLog.addTarget("syslog:7,anytun,daemon"); + cLog.addTarget("syslog:5,anytun,daemon"); #else #ifdef WIN_SERVICE - cLog.addTarget("eventlog:7,anytun"); + cLog.addTarget("eventlog:5,anytun"); #else - cLog.addTarget("stdout:7"); + cLog.addTarget("stdout:5"); #endif #endif - cLog.msg(Log::PRIO_NOTICE) << "anytun started..."; -/// std::cout << "anytun - secure anycast tunneling protocol" << std::endl; - - bool result = gOpt.parse(argc, argv); - if(!result) { - cLog.msg(Log::PRIO_NOTICE) << "printing help text and exitting"; - gOpt.printUsage(); - exit(0); + } + 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); } + cLog.msg(Log::PRIO_NOTICE) << "anytun started..."; + gOpt.parse_post(); // print warnings + #ifndef NO_DAEMON #ifndef NO_PRIVDROP PrivInfo privs(gOpt.getUsername(), gOpt.getGroupname()); -- cgit v1.2.3