diff options
author | Bernard Normier <bernard@zeroc.com> | 2012-10-22 12:56:41 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2012-10-22 12:56:41 -0400 |
commit | f1b727794617cc064d3aabee1e981cd4dcd07051 (patch) | |
tree | d4c18e607ad7059de11c06dd096dd28ee1f508f6 /cpp/src/IceGrid/IceGridNode.cpp | |
parent | Merge branch 'master' of ssh://git/home/git/ice (diff) | |
download | ice-f1b727794617cc064d3aabee1e981cd4dcd07051.tar.bz2 ice-f1b727794617cc064d3aabee1e981cd4dcd07051.tar.xz ice-f1b727794617cc064d3aabee1e981cd4dcd07051.zip |
Fixed ICE-4882:
Better logging in C++, especially with services. On compilers with
stack-trace printing support, the stack trace of most exceptions is
now logged.
Diffstat (limited to 'cpp/src/IceGrid/IceGridNode.cpp')
-rw-r--r-- | cpp/src/IceGrid/IceGridNode.cpp | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 0c26b17ceda..210c1563fed 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -350,12 +350,12 @@ NodeService::startImpl(int argc, char* argv[], int& status) { if(!IceUtilInternal::directoryExists(dataPath)) { - ostringstream os; FileException ex(__FILE__, __LINE__); ex.path = dataPath; ex.error = IceInternal::getSystemErrno(); - os << ex; - error("property `IceGrid.Node.Data' is set to an invalid path:\n" + os.str()); + + ServiceError err(this); + err << "property `IceGrid.Node.Data' is set to an invalid path:\n" << ex; return false; } @@ -434,11 +434,10 @@ NodeService::startImpl(int argc, char* argv[], int& status) { mapper = UserAccountMapperPrx::uncheckedCast(communicator()->propertyToProxy(mapperProperty)); } - catch(const Ice::LocalException& ex) + catch(const std::exception& ex) { - ostringstream os; - os << "user account mapper `" << mapperProperty << "' is invalid:\n" << ex; - error(os.str()); + ServiceError err(this); + err << "user account mapper `" << mapperProperty << "' is invalid:\n" << ex; return false; } } @@ -627,28 +626,24 @@ NodeService::startImpl(int argc, char* argv[], int& status) } catch(const DeploymentException& ex) { - ostringstream ostr; - ostr << "failed to deploy application `" << desc << "':\n" << ex << ": " << ex.reason; - warning(ostr.str()); + ServiceWarning warn(this); + warn << "failed to deploy application `" << desc << "':\n" << ex; } catch(const AccessDeniedException& ex) { - ostringstream ostr; - ostr << "failed to deploy application `" << desc << "':\n" + ServiceWarning warn(this); + warn << "failed to deploy application `" << desc << "':\n" << "registry database is locked by `" << ex.lockUserId << "'"; - warning(ostr.str()); } catch(const std::exception& ex) { - ostringstream ostr; - ostr << "failed to deploy application `" << desc << "':\n" << ex.what(); - warning(ostr.str()); + ServiceWarning warn(this); + warn << "failed to deploy application `" << desc << "':\n" << ex; } catch(const string& reason) { - ostringstream ostr; - ostr << "failed to deploy application `" << desc << "':\n" << reason; - warning(ostr.str()); + ServiceWarning warn(this); + warn << "failed to deploy application `" << desc << "':\n" << reason; } } @@ -716,11 +711,10 @@ NodeService::stop() _adapter->deactivate(); _adapter = 0; } - catch(const Ice::LocalException& ex) + catch(const std::exception& ex) { - ostringstream ostr; - ostr << "unexpected exception while shutting down node:\n" << ex; - warning(ostr.str()); + ServiceWarning warn(this); + warn << "unexpected exception while shutting down node:\n" << ex; } } @@ -745,11 +739,10 @@ NodeService::stop() communicator()->shutdown(); communicator()->waitForShutdown(); } - catch(const Ice::LocalException& ex) + catch(const std::exception& ex) { - ostringstream ostr; - ostr << "unexpected exception while shutting down node:\n" << ex; - warning(ostr.str()); + ServiceWarning warn(this); + warn << "unexpected exception while shutting down node:\n" << ex; } // |