From 19aed06df786797d528ece7e1350771f6c79853c Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 16 Dec 2011 20:05:52 +0000 Subject: Improved connection failure logging and instantiation --- project2/sql/rdbmsDataSource.cpp | 8 +++++--- project2/sql/rdbmsDataSource.h | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/project2/sql/rdbmsDataSource.cpp b/project2/sql/rdbmsDataSource.cpp index 4c6ae17..305f1d7 100644 --- a/project2/sql/rdbmsDataSource.cpp +++ b/project2/sql/rdbmsDataSource.cpp @@ -159,6 +159,8 @@ RdbmsDataSource::connectTo(const ConnectionInfo & dsn) return db; } catch (const DB::ConnectionError & e) { + Logger()->messagef(LOG_NOTICE, "%s: connection error message to '%s' -> %s", + __PRETTY_FUNCTION__, dsn.dsn.c_str(), e.what()); failedhosts.insert(FailedHosts::value_type(dsn, e)); throw; } @@ -190,10 +192,10 @@ RdbmsDataSource::RdbmsConnection::isExpired() const return (time(NULL) > lastUsedTime + keepAliveTime); } -RdbmsDataSource::ConnectionInfo::ConnectionInfo(ScriptNodePtr node) +RdbmsDataSource::ConnectionInfo::ConnectionInfo(ScriptNodePtr node) : + dsn(node->value("dsn").as()), + typeId(LoaderBase::getLoader(node->value("provider"))) { - typeId = LoaderBase::getLoader(node->value("provider")); - dsn = node->value("dsn").as(); } DB::Connection * diff --git a/project2/sql/rdbmsDataSource.h b/project2/sql/rdbmsDataSource.h index b991cc4..c0345a0 100644 --- a/project2/sql/rdbmsDataSource.h +++ b/project2/sql/rdbmsDataSource.h @@ -37,9 +37,8 @@ class RdbmsDataSource : public DataSource { bool operator<(const ConnectionInfo & o) const; - private: - std::string dsn; - boost::shared_ptr typeId; + const std::string dsn; + const boost::shared_ptr typeId; }; typedef boost::shared_ptr ConnectionPtr; -- cgit v1.2.3