summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-12-16 20:05:52 +0000
committerrandomdan <randomdan@localhost>2011-12-16 20:05:52 +0000
commit19aed06df786797d528ece7e1350771f6c79853c (patch)
tree09e86723b406d9d5e73e27390069670507d96b88
parentImprovements to the handling of command line arguments (diff)
downloadproject2-19aed06df786797d528ece7e1350771f6c79853c.tar.bz2
project2-19aed06df786797d528ece7e1350771f6c79853c.tar.xz
project2-19aed06df786797d528ece7e1350771f6c79853c.zip
Improved connection failure logging and instantiation
-rw-r--r--project2/sql/rdbmsDataSource.cpp8
-rw-r--r--project2/sql/rdbmsDataSource.h5
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;