diff options
author | Michi Henning <michi@zeroc.com> | 2005-01-13 07:16:45 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2005-01-13 07:16:45 +0000 |
commit | 26d464a9e90ec682765772250e6634be625f42d1 (patch) | |
tree | 92a2f0370e758f28db8283b1442d4e511df61462 /cpp/src/IcePatch2/Server.cpp | |
parent | Fixed bug in the way the arguments were passed to a service. I'm not sure (diff) | |
download | ice-26d464a9e90ec682765772250e6634be625f42d1.tar.bz2 ice-26d464a9e90ec682765772250e6634be625f42d1.tar.xz ice-26d464a9e90ec682765772250e6634be625f42d1.zip |
Added print() operation to Ice::Logger and changed icepatch2server to use
logger instead of writing to stderr.
Diffstat (limited to 'cpp/src/IcePatch2/Server.cpp')
-rw-r--r-- | cpp/src/IcePatch2/Server.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/cpp/src/IcePatch2/Server.cpp b/cpp/src/IcePatch2/Server.cpp index 52bb0559243..a06d8b1889e 100644 --- a/cpp/src/IcePatch2/Server.cpp +++ b/cpp/src/IcePatch2/Server.cpp @@ -58,6 +58,8 @@ protected: private: void usage(const std::string&); + + LoggerPtr _logger; }; }; @@ -69,6 +71,8 @@ IcePatch2::PatcherService::PatcherService() bool IcePatch2::PatcherService::start(int argc, char* argv[]) { + _logger = communicator()->getLogger(); + string dataDir; IceUtil::Options opts; @@ -82,7 +86,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[]) } catch(const IceUtil::Options::BadOpt& e) { - cerr << e.reason << endl; + _logger->error(e.reason); usage(argv[0]); return false; } @@ -94,13 +98,13 @@ IcePatch2::PatcherService::start(int argc, char* argv[]) } if(opts.isSet("v") || opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + _logger->print(ICE_STRING_VERSION); return false; } if(args.size() > 1) { - cerr << argv[0] << ": too many arguments" << endl; + _logger->error("too many arguments"); usage(argv[0]); return false; } @@ -116,7 +120,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[]) dataDir = properties->getProperty("IcePatch2.Directory"); if(dataDir.empty()) { - cerr << argv[0] << ": no data directory specified" << endl; + _logger->error("no data directory specified"); usage(argv[0]); return false; } @@ -141,19 +145,21 @@ IcePatch2::PatcherService::start(int argc, char* argv[]) } catch(const string& ex) { - cerr << argv[0] << ": " << ex << endl; + _logger->error(ex); return false; } catch(const char* ex) { - cerr << argv[0] << ": " << ex << endl; + _logger->error(ex); return false; } const char* endpointsProperty = "IcePatch2.Endpoints"; if(properties->getProperty(endpointsProperty).empty()) { - cerr << argv[0] << ": property `" << endpointsProperty << "' is not set" << endl; + ostringstream os; + os << "property `" << endpointsProperty << "' is not set"; + _logger->error(os.str()); return false; } ObjectAdapterPtr adapter = communicator()->createObjectAdapter("IcePatch2"); @@ -237,8 +243,8 @@ IcePatch2::PatcherService::usage(const string& appName) // --nochdir is intentionally not shown here. (See the comment in main().) ); #endif - cerr << "Usage: " << appName << " [options] [DIR]" << endl; - cerr << options << endl; + _logger->print("Usage: " + appName + " [options] [DIR]"); + _logger->print(options); } int @@ -278,7 +284,7 @@ main(int argc, char* argv[]) try { status = svc.main(argc + 1, v); - } + u catch(...) { // Ignore exceptions -- the only thing left to do is to free memory. |