diff options
author | Marc Laukien <marc@zeroc.com> | 2002-02-10 15:29:28 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-02-10 15:29:28 +0000 |
commit | f0ca968ad2c33ef03d303518150cb31df827c51b (patch) | |
tree | b7c25c8877e5bd5680d1b3df9d36f0f6fe6d1514 /cpp | |
parent | fixes (diff) | |
download | ice-f0ca968ad2c33ef03d303518150cb31df827c51b.tar.bz2 ice-f0ca968ad2c33ef03d303518150cb31df827c51b.tar.xz ice-f0ca968ad2c33ef03d303518150cb31df827c51b.zip |
switched to LoggerUtil
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/Freeze/DBI.cpp | 110 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 37 | ||||
-rw-r--r-- | cpp/src/Glacier/ClientBlobject.cpp | 21 | ||||
-rw-r--r-- | cpp/src/Glacier/GlacierI.cpp | 22 | ||||
-rw-r--r-- | cpp/src/Glacier/RouterI.cpp | 5 | ||||
-rw-r--r-- | cpp/src/Glacier/ServerBlobject.cpp | 21 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.cpp | 12 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.cpp | 5 |
8 files changed, 97 insertions, 136 deletions
diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp index 5d114689678..6ca18413f97 100644 --- a/cpp/src/Freeze/DBI.cpp +++ b/cpp/src/Freeze/DBI.cpp @@ -83,9 +83,8 @@ Freeze::DBEnvironmentI::DBEnvironmentI(const CommunicatorPtr& communicator, cons if (_trace >= 1) { - ostringstream s; - s << "opening database environment \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "opening database environment \"" << _name << "\""; } checkBerkeleyDBReturn(_dbEnv->open(_dbEnv, _name.c_str(), @@ -102,9 +101,8 @@ Freeze::DBEnvironmentI::~DBEnvironmentI() { if (_dbEnv) { - ostringstream s; - s << _errorPrefix << "\"" << _name << "\" has not been closed"; - _communicator->getLogger()->warning(s.str()); + Warning out(_communicator->getLogger()); + out << _errorPrefix << "\"" << _name << "\" has not been closed"; } } @@ -191,9 +189,8 @@ Freeze::DBEnvironmentI::close() if (_trace >= 1) { - ostringstream s; - s << "closing database environment \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "closing database environment \"" << _name << "\""; } checkBerkeleyDBReturn(_dbEnv->close(_dbEnv, 0), _errorPrefix, "DB_ENV->close"); @@ -262,9 +259,8 @@ Freeze::DBTransactionI::DBTransactionI(const CommunicatorPtr& communicator, ::DB if (_trace >= 2) { - ostringstream s; - s << "starting transaction for environment \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "starting transaction for environment \"" << _name << "\""; } checkBerkeleyDBReturn(txn_begin(dbEnv, 0, &_tid, 0), _errorPrefix, "txn_begin"); @@ -274,9 +270,8 @@ Freeze::DBTransactionI::~DBTransactionI() { if (_tid) { - ostringstream s; - s << _errorPrefix << "transaction has not been committed or aborted"; - _communicator->getLogger()->warning(s.str()); + Warning out(_communicator->getLogger()); + out << _errorPrefix << "transaction has not been committed or aborted"; } } @@ -296,9 +291,8 @@ Freeze::DBTransactionI::commit() if (_trace >= 2) { - ostringstream s; - s << "committing transaction for environment \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "committing transaction for environment \"" << _name << "\""; } checkBerkeleyDBReturn(txn_commit(_tid, 0), _errorPrefix, "txn_commit"); @@ -322,9 +316,8 @@ Freeze::DBTransactionI::abort() if (_trace >= 2) { - ostringstream s; - s << "aborting transaction for environment \"" << _name << "\" due to deadlock"; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "aborting transaction for environment \"" << _name << "\" due to deadlock"; } checkBerkeleyDBReturn(txn_abort(_tid), _errorPrefix, "txn_abort"); @@ -351,9 +344,8 @@ DBCursorI::DBCursorI(const ::Ice::CommunicatorPtr& communicator, const std::stri if (_trace >= 1) { - ostringstream s; - s << "creating cursor for \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "creating cursor for \"" << _name << "\""; } } @@ -361,9 +353,8 @@ DBCursorI::~DBCursorI() { if (_cursor != 0) { - ostringstream s; - s << _errorPrefix << "\"" << _name << "\" has not been closed"; - _communicator->getLogger()->warning(s.str()); + Warning out(_communicator->getLogger()); + out << _errorPrefix << "\"" << _name << "\" has not been closed"; } } @@ -394,9 +385,8 @@ DBCursorI::curr(Key& key, Value& value) if (_trace >= 1) { - ostringstream s; - s << "reading current value from database \"" << _name << "\""; - _communicator->getLogger()->trace("DBCursor", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "reading current value from database \"" << _name << "\""; } checkBerkeleyDBReturn(_cursor->c_get(_cursor, &dbKey, &dbData, DB_CURRENT), _errorPrefix, "DBcursor->c_get"); @@ -430,9 +420,8 @@ DBCursorI::set(const Value& value) if (_trace >= 1) { - ostringstream s; - s << "reading current value from database \"" << _name << "\""; - _communicator->getLogger()->trace("DBCursor", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "reading current value from database \"" << _name << "\""; } // @@ -467,9 +456,8 @@ DBCursorI::next() if (_trace >= 1) { - ostringstream s; - s << "moving to next value in database \"" << _name << "\""; - _communicator->getLogger()->trace("DBCursor", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "moving to next value in database \"" << _name << "\""; } try @@ -509,9 +497,8 @@ DBCursorI::prev() if (_trace >= 1) { - ostringstream s; - s << "moving to previous value in database \"" << _name << "\""; - _communicator->getLogger()->trace("DBCursor", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "moving to previous value in database \"" << _name << "\""; } try @@ -541,9 +528,8 @@ DBCursorI::del() if (_trace >= 1) { - ostringstream s; - s << "removing the current element in database \"" << _name << "\""; - _communicator->getLogger()->trace("DBCursor", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "removing the current element in database \"" << _name << "\""; } checkBerkeleyDBReturn(_cursor->c_del(_cursor, 0), _errorPrefix, "DBcursor->c_del"); @@ -580,9 +566,8 @@ DBCursorI::close() if (_trace >= 1) { - ostringstream s; - s << "closing cursor \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "closing cursor \"" << _name << "\""; } _cursor->c_close(_cursor); @@ -610,9 +595,8 @@ Freeze::DBI::DBI(const CommunicatorPtr& communicator, const DBEnvironmentIPtr& d if (_trace >= 1) { - ostringstream s; - s << "opening database \"" << _name << "\" in environment \"" << _dbEnvObj->getName() << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "opening database \"" << _name << "\" in environment \"" << _dbEnvObj->getName() << "\""; } u_int32_t flags = (create) ? DB_CREATE : 0; @@ -626,9 +610,8 @@ Freeze::DBI::~DBI() { if (_db) { - ostringstream s; - s << _errorPrefix << "\"" << _name << "\" has not been closed"; - _communicator->getLogger()->warning(s.str()); + Warning out(_communicator->getLogger()); + out << _errorPrefix << "\"" << _name << "\" has not been closed"; } } @@ -790,9 +773,8 @@ Freeze::DBI::put(const Key& key, const Value& value) if (_trace >= 1) { - ostringstream s; - s << "writing value in database \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "writing value in database \"" << _name << "\""; } checkBerkeleyDBReturn(_db->put(_db, 0, &dbKey, &dbData, 0), _errorPrefix, "DB->put"); @@ -820,9 +802,8 @@ Freeze::DBI::get(const Key& key) if (_trace >= 1) { - ostringstream s; - s << "reading value from database \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "reading value from database \"" << _name << "\""; } checkBerkeleyDBReturn(_db->get(_db, 0, &dbKey, &dbData, 0), _errorPrefix, "DB->get"); @@ -851,9 +832,8 @@ Freeze::DBI::del(const Key& key) if (_trace >= 1) { - ostringstream s; - s << "deleting value from database \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "deleting value from database \"" << _name << "\""; } checkBerkeleyDBReturn(_db->del(_db, 0, &dbKey, 0), _errorPrefix, "DB->del"); @@ -889,9 +869,8 @@ Freeze::DBI::close() if (_trace >= 1) { - ostringstream s; - s << "closing database \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "closing database \"" << _name << "\""; } checkBerkeleyDBReturn(_db->close(_db, 0), _errorPrefix, "DB->close"); @@ -913,9 +892,8 @@ Freeze::DBI::remove() if (_trace >= 1) { - ostringstream s; - s << "removing database \"" << _name << "\""; - _communicator->getLogger()->trace("DB", s.str()); + Trace out(_communicator->getLogger(), "DB"); + out << "removing database \"" << _name << "\""; } // diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 94d73959835..1b242c86e93 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -37,7 +37,8 @@ Freeze::EvictorI::~EvictorI() { if (!_deactivated) { - _db->getCommunicator()->getLogger()->warning("evictor has not been deactivated"); + Warning out(_db->getCommunicator()->getLogger()); + out << "evictor has not been deactivated"; } } @@ -114,9 +115,8 @@ Freeze::EvictorI::createObject(const Identity& ident, const ObjectPtr& servant) if (_trace >= 1) { - ostringstream s; - s << "created \"" << ident << "\""; - _db->getCommunicator()->getLogger()->trace("Evictor", s.str()); + Trace out(_db->getCommunicator()->getLogger(), "Evictor"); + out << "created \"" << ident << "\""; } // @@ -143,9 +143,8 @@ Freeze::EvictorI::destroyObject(const Identity& ident) if (_trace >= 1) { - ostringstream s; - s << "destroyed \"" << ident << "\""; - _db->getCommunicator()->getLogger()->trace("Evictor", s.str()); + Trace out(_db->getCommunicator()->getLogger(), "Evictor"); + out << "destroyed \"" << ident << "\""; } } @@ -182,9 +181,8 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const Current& current { if (_trace >= 2) { - ostringstream s; - s << "found \"" << current.identity << "\" in the queue"; - _db->getCommunicator()->getLogger()->trace("Evictor", s.str()); + Trace out(_db->getCommunicator()->getLogger(), "Evictor"); + out << "found \"" << current.identity << "\" in the queue"; } // @@ -200,10 +198,9 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const Current& current { if (_trace >= 2) { - ostringstream s; - s << "couldn't find \"" << current.identity << "\" in the queue\n" - << "loading \"" << current.identity << "\" from the database"; - _db->getCommunicator()->getLogger()->trace("Evictor", s.str()); + Trace out(_db->getCommunicator()->getLogger(), "Evictor"); + out << "couldn't find \"" << current.identity << "\" in the queue\n" + << "loading \"" << current.identity << "\" from the database"; } // @@ -309,9 +306,8 @@ Freeze::EvictorI::deactivate() if (_trace >= 1) { - ostringstream s; - s << "deactivating, saving unsaved Ice Objects to the database"; - _db->getCommunicator()->getLogger()->trace("Evictor", s.str()); + Trace out(_db->getCommunicator()->getLogger(), "Evictor"); + out << "deactivating, saving unsaved Ice Objects to the database"; } // @@ -376,10 +372,9 @@ Freeze::EvictorI::evict() if (_trace >= 2) { - ostringstream s; - s << "evicted \"" << ident << "\" from the queue\n" - << "number of elements in the queue: " << _evictorMap.size(); - _db->getCommunicator()->getLogger()->trace("Evictor", s.str()); + Trace out(_db->getCommunicator()->getLogger(), "Evictor"); + out << "evicted \"" << ident << "\" from the queue\n" + << "number of elements in the queue: " << _evictorMap.size(); } } diff --git a/cpp/src/Glacier/ClientBlobject.cpp b/cpp/src/Glacier/ClientBlobject.cpp index b63325def58..87bad386bd5 100644 --- a/cpp/src/Glacier/ClientBlobject.cpp +++ b/cpp/src/Glacier/ClientBlobject.cpp @@ -96,9 +96,8 @@ Glacier::ClientBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vect default: { - ostringstream s; - s << "unknown forward option `" << option << "'"; - _logger->warning(s.str()); + Warning out(_logger); + out << "unknown forward option `" << option << "'"; break; } } @@ -107,12 +106,11 @@ Glacier::ClientBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vect if (_traceLevel >= 2) { - ostringstream s; - s << "routing to:\n" - << "proxy = " << _communicator->proxyToString(proxy) << '\n' - << "operation = " << current.operation << '\n' - << "nonmutating = " << (current.nonmutating ? "true" : "false"); - _logger->trace("Glacier", s.str()); + Trace out(_logger, "Glacier"); + out << "routing to:\n" + << "proxy = " << _communicator->proxyToString(proxy) << '\n' + << "operation = " << current.operation << '\n' + << "nonmutating = " << (current.nonmutating ? "true" : "false"); } return proxy->ice_invoke(current.operation, current.nonmutating, inParams, outParams, current.context); @@ -121,9 +119,8 @@ Glacier::ClientBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vect { if (_traceLevel) { - ostringstream s; - s << "routing exception:\n" << ex; - _logger->trace("Glacier", s.str()); + Trace out(_logger, "Glacier"); + out << "routing exception:\n" << ex; } ex.ice_throw(); diff --git a/cpp/src/Glacier/GlacierI.cpp b/cpp/src/Glacier/GlacierI.cpp index 82861ada133..bd4d76da1d3 100644 --- a/cpp/src/Glacier/GlacierI.cpp +++ b/cpp/src/Glacier/GlacierI.cpp @@ -81,10 +81,8 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, con } catch(const LocalException& ex) { - ostringstream s; - s << ex; - _logger->error(s.str()); - + Error out(_logger); + out << ex; ex.ice_throw(); } @@ -269,9 +267,8 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, con if (_traceLevel >= 2) { - ostringstream s; - s << "started new router:\n" << _communicator->proxyToString(router); - _logger->trace("Glacier", s.str()); + Trace out(_logger, "Glacier"); + out << "started new router:\n" << _communicator->proxyToString(router); } return router; @@ -290,19 +287,16 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, con { if (_traceLevel >= 1) { - ostringstream s; - s << "router starter exception:\n" << ex << ":\n" << ex.reason; - _logger->trace("Glacier", s.str()); + Trace out(_logger, "Glacier"); + out << "router starter exception:\n" << ex << ":\n" << ex.reason; } ex.ice_throw(); } catch(const Exception& ex) { - ostringstream s; - s << ex; - _logger->error(s.str()); - + Error out(_logger); + out << ex; ex.ice_throw(); } } diff --git a/cpp/src/Glacier/RouterI.cpp b/cpp/src/Glacier/RouterI.cpp index 96b8fb03ab6..b2e1ef3b395 100644 --- a/cpp/src/Glacier/RouterI.cpp +++ b/cpp/src/Glacier/RouterI.cpp @@ -75,9 +75,8 @@ Glacier::RouterI::addProxy(const ObjectPrx& proxy, const Current&) if (_routingTableTraceLevel) { - ostringstream s; - s << "adding proxy to routing table:\n" << _clientAdapter->getCommunicator()->proxyToString(proxy); - _logger->trace("Glacier", s.str()); + Trace out(_logger, "Glacier"); + out << "adding proxy to routing table:\n" << _clientAdapter->getCommunicator()->proxyToString(proxy); } _routingTable->add(proxy); diff --git a/cpp/src/Glacier/ServerBlobject.cpp b/cpp/src/Glacier/ServerBlobject.cpp index 1d14998e2fc..bb99bfb0f38 100644 --- a/cpp/src/Glacier/ServerBlobject.cpp +++ b/cpp/src/Glacier/ServerBlobject.cpp @@ -89,9 +89,8 @@ Glacier::ServerBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vect default: { - ostringstream s; - s << "unknown forward option `" << option << "'"; - _logger->warning(s.str()); + Warning out(_logger); + out << "unknown forward option `" << option << "'"; break; } } @@ -100,12 +99,11 @@ Glacier::ServerBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vect if (_traceLevel >= 2) { - ostringstream s; - s << "reverse routing to:\n" - << "proxy = " << _clientAdapter->getCommunicator()->proxyToString(proxy) << '\n' - << "operation = " << current.operation << '\n' - << "nonmutating = " << (current.nonmutating ? "true" : "false"); - _logger->trace("Glacier", s.str()); + Trace out(_logger, "Glacier"); + out << "reverse routing to:\n" + << "proxy = " << _clientAdapter->getCommunicator()->proxyToString(proxy) << '\n' + << "operation = " << current.operation << '\n' + << "nonmutating = " << (current.nonmutating ? "true" : "false"); } return proxy->ice_invoke(current.operation, current.nonmutating, inParams, outParams, current.context); @@ -114,9 +112,8 @@ Glacier::ServerBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vect { if (_traceLevel) { - ostringstream s; - s << "reverse routing exception:\n" << ex; - _logger->trace("Glacier", s.str()); + Trace out(_logger, "Glacier"); + out << "reverse routing exception:\n" << ex; } ex.ice_throw(); diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp index 160809147ed..67c2ccca319 100644 --- a/cpp/src/IcePack/Activator.cpp +++ b/cpp/src/IcePack/Activator.cpp @@ -56,13 +56,13 @@ IcePack::Activator::run() } catch (const LocalException& ex) { - ostringstream s; - s << "exception in process termination listener:\n" << ex; - _communicator->getLogger()->error(s.str()); + Error out(_communicator->getLogger()); + out << "exception in process termination listener:\n" << ex; } catch (...) { - _communicator->getLogger()->error("unknown exception in process termination listener"); + Error out(_communicator->getLogger()); + out << "unknown exception in process termination listener"; } } @@ -290,7 +290,9 @@ IcePack::Activator::terminationListener() ret = read(fd, &s, 16); } while (ret != 0); - _communicator->getLogger()->error(err); + + Error out(_communicator->getLogger()); + out << err; } } else diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index f222b1b7879..5c8829cc05a 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -147,9 +147,8 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const Current& current // to send a location forward to the client, which will // then get a similar exception. // - ostringstream s; - s << "exception during server activation:\n" << ex; - _communicator->getLogger()->error(s.str()); + Error out(_communicator->getLogger()); + out << "exception during server activation:\n" << ex; } } |