aboutsummaryrefslogtreecommitdiffstats
path: root/CommonLibs/Configuration.cpp
diff options
context:
space:
mode:
authorkurtis.heimerl <kurtis.heimerl@19bc5d8c-e614-43d4-8b26-e1612bc8e597>2012-12-16 06:08:18 +0000
committerkurtis.heimerl <kurtis.heimerl@19bc5d8c-e614-43d4-8b26-e1612bc8e597>2012-12-16 06:08:18 +0000
commit00913d74d9d3d9e270a5624513adc3939b257ff1 (patch)
tree679554be25614c9fc9aff1741f8840d843f0d90e /CommonLibs/Configuration.cpp
parentdb70eb4c6e3837e0561be36fcc612f65722e037b (diff)
Sylvain patch #2, with modifications:
CommonLibs: Avoid direct syslog calls in ConfigurationTable We instead introduce a 'log early' facility in Logger.h to accomplish the same Signed-off-by: Sylvain Munaut <tnt@246tNt.com> I added similar code to the reporting functions, which did not exist when sylvain made this patch git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@4629 19bc5d8c-e614-43d4-8b26-e1612bc8e597
Diffstat (limited to 'CommonLibs/Configuration.cpp')
-rw-r--r--CommonLibs/Configuration.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/CommonLibs/Configuration.cpp b/CommonLibs/Configuration.cpp
index 7d0bea2..5dcc277 100644
--- a/CommonLibs/Configuration.cpp
+++ b/CommonLibs/Configuration.cpp
@@ -27,10 +27,11 @@
#include "Configuration.h"
+#include "Logger.h"
#include <fstream>
#include <iostream>
#include <string.h>
-#include <syslog.h>
+
using namespace std;
@@ -56,10 +57,9 @@ float ConfigurationRecord::floatNumber() const
}
-ConfigurationTable::ConfigurationTable(const char* filename, const char *wCmdName, int wFacility)
- :mFacility(wFacility)
+ConfigurationTable::ConfigurationTable(const char* filename, const char *wCmdName)
{
- syslog(LOG_INFO | mFacility, "opening configuration table from path %s", filename);
+ gLogEarly(LOG_INFO, "opening configuration table from path %s", filename);
// Connect to the database.
int rc = sqlite3_open(filename,&mDB);
// (pat) When I used malloc here, sqlite3 sporadically crashes.
@@ -69,14 +69,14 @@ ConfigurationTable::ConfigurationTable(const char* filename, const char *wCmdNam
strcat(gCmdName,":");
}
if (rc) {
- syslog(LOG_EMERG | mFacility, "cannot open configuration database at %s, error message: %s", filename, sqlite3_errmsg(mDB));
+ gLogEarly(LOG_EMERG, "cannot open configuration database at %s, error message: %s", filename, sqlite3_errmsg(mDB));
sqlite3_close(mDB);
mDB = NULL;
return;
}
// Create the table, if needed.
if (!sqlite3_command(mDB,createConfigTable)) {
- syslog(LOG_EMERG | mFacility, "cannot create configuration table in database at %s, error message: %s", filename, sqlite3_errmsg(mDB));
+ gLogEarly(LOG_EMERG, "cannot create configuration table in database at %s, error message: %s", filename, sqlite3_errmsg(mDB));
}
}
@@ -175,7 +175,7 @@ string ConfigurationTable::getStr(const string& key)
return lookup(key).value();
} catch (ConfigurationTableKeyNotFound) {
// Raise an alert and re-throw the exception.
- syslog(LOG_ALERT | mFacility, "configuration parameter %s has no defined value", key.c_str());
+ gLogEarly(LOG_ALERT, "configuration parameter %s has no defined value", key.c_str());
throw ConfigurationTableKeyNotFound(key);
}
}
@@ -186,7 +186,7 @@ string ConfigurationTable::getStr(const string& key, const char* defaultValue)
ScopedLock lock(mLock);
return lookup(key).value();
} catch (ConfigurationTableKeyNotFound) {
- syslog(LOG_NOTICE | mFacility, "deinfing missing parameter %s with value %s", key.c_str(),defaultValue);
+ gLogEarly(LOG_NOTICE, "deinfing missing parameter %s with value %s", key.c_str(),defaultValue);
set(key,defaultValue);
return string(defaultValue);
}
@@ -211,7 +211,7 @@ long ConfigurationTable::getNum(const string& key)
return lookup(key).number();
} catch (ConfigurationTableKeyNotFound) {
// Raise an alert and re-throw the exception.
- syslog(LOG_ALERT | mFacility, "configuration parameter %s has no defined value", key.c_str());
+ gLogEarly(LOG_ALERT, "configuration parameter %s has no defined value", key.c_str());
throw ConfigurationTableKeyNotFound(key);
}
}
@@ -223,7 +223,7 @@ long ConfigurationTable::getNum(const string& key, long defaultValue)
ScopedLock lock(mLock);
return lookup(key).number();
} catch (ConfigurationTableKeyNotFound) {
- syslog(LOG_NOTICE | mFacility, "deinfing missing parameter %s with value %ld", key.c_str(),defaultValue);
+ gLogEarly(LOG_NOTICE, "deinfing missing parameter %s with value %ld", key.c_str(),defaultValue);
set(key,defaultValue);
return defaultValue;
}
@@ -247,7 +247,7 @@ std::vector<string> ConfigurationTable::getVectorOfStrings(const string& key)
line = strdup(rec.value().c_str());
} catch (ConfigurationTableKeyNotFound) {
// Raise an alert and re-throw the exception.
- syslog(LOG_ALERT | mFacility, "configuration parameter %s has no defined value", key.c_str());
+ gLogEarly(LOG_ALERT, "configuration parameter %s has no defined value", key.c_str());
throw ConfigurationTableKeyNotFound(key);
}
@@ -289,7 +289,7 @@ std::vector<unsigned> ConfigurationTable::getVector(const string& key)
line = strdup(rec.value().c_str());
} catch (ConfigurationTableKeyNotFound) {
// Raise an alert and re-throw the exception.
- syslog(LOG_ALERT | mFacility, "configuration parameter %s has no defined value", key.c_str());
+ gLogEarly(LOG_ALERT, "configuration parameter %s has no defined value", key.c_str());
throw ConfigurationTableKeyNotFound(key);
}