diff options
author | randomdan <randomdan@localhost> | 2011-12-16 20:05:52 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-12-16 20:05:52 +0000 |
commit | 6b69aea029b3c2978995c3fad017194a1a4927d8 (patch) | |
tree | 09e86723b406d9d5e73e27390069670507d96b88 | |
parent | Improvements to the handling of command line arguments (diff) | |
download | project2-6b69aea029b3c2978995c3fad017194a1a4927d8.tar.bz2 project2-6b69aea029b3c2978995c3fad017194a1a4927d8.tar.xz project2-6b69aea029b3c2978995c3fad017194a1a4927d8.zip |
Improved connection failure logging and instantiation
-rw-r--r-- | project2/sql/rdbmsDataSource.cpp | 8 | ||||
-rw-r--r-- | 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<std::string>()), + typeId(LoaderBase::getLoader<ConnectionLoader, UnknownConnectionProvider>(node->value("provider"))) { - typeId = LoaderBase::getLoader<ConnectionLoader, UnknownConnectionProvider>(node->value("provider")); - dsn = node->value("dsn").as<std::string>(); } 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<ConnectionLoader> typeId; + const std::string dsn; + const boost::shared_ptr<ConnectionLoader> typeId; }; typedef boost::shared_ptr<RdbmsConnection> ConnectionPtr; |