diff options
author | Mark Spruiell <mes@zeroc.com> | 2006-06-08 17:16:27 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2006-06-08 17:16:27 +0000 |
commit | 43f0359aef87e20359495af39b104fd1edcd45cd (patch) | |
tree | b15ec05993ee6ecaed7acbc43df697b354be7fe6 /cpp/src | |
parent | Make copy of InitializationData (diff) | |
download | ice-43f0359aef87e20359495af39b104fd1edcd45cd.tar.bz2 ice-43f0359aef87e20359495af39b104fd1edcd45cd.tar.xz ice-43f0359aef87e20359495af39b104fd1edcd45cd.zip |
use the logger from InitializationData if one is provided
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Ice/Service.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index 8379d315813..4bf5f7de84b 100755 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -204,40 +204,46 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initData) if(strcmp(argv[idx], "--service") == 0) { // - // When running as a service, we need an event logger in order to report + // When running as a service, we need a logger to use for reporting any // failures that occur prior to initializing a communicator. After we have - // a communicator, we can use the configured logger instead. + // a communicator, we can use the configured logger instead. If a logger + // is defined in InitializationData, we'll use that. Otherwise, we create + // a temporary event logger. // // We postpone the initialization of the communicator until serviceMain so // that we can incorporate the executable's arguments and the service's // arguments into one vector. // - try + _logger = initData.logger; + if(!_logger) { - // - // Use the executable name as the source for the temporary logger. - // - string loggerName = _name; - transform(loggerName.begin(), loggerName.end(), loggerName.begin(), ::tolower); - string::size_type pos = loggerName.find_last_of("\\/"); - if(pos != string::npos) + try { - loggerName.erase(0, pos + 1); // Remove leading path. + // + // Use the executable name as the source for the temporary logger. + // + string loggerName = _name; + transform(loggerName.begin(), loggerName.end(), loggerName.begin(), ::tolower); + string::size_type pos = loggerName.find_last_of("\\/"); + if(pos != string::npos) + { + loggerName.erase(0, pos + 1); // Remove leading path. + } + pos = loggerName.rfind(".exe"); + if(pos != string::npos) + { + loggerName.erase(pos, loggerName.size() - pos); // Remove .exe extension. + } + + _logger = new EventLoggerI(loggerName); } - pos = loggerName.rfind(".exe"); - if(pos != string::npos) + catch(const IceUtil::Exception& ex) { - loggerName.erase(pos, loggerName.size() - pos); // Remove .exe extension. + ostringstream ostr; + ostr << ex; + error("unable to create EventLogger:\n" + ostr.str()); + return EXIT_FAILURE; } - - _logger = new EventLoggerI(loggerName); - } - catch(const IceUtil::Exception& ex) - { - ostringstream ostr; - ostr << ex; - error("unable to create EventLogger:\n" + ostr.str()); - return EXIT_FAILURE; } if(idx + 1 >= argc) |