Commit 9ea10688 authored by Ronan's avatar Ronan

feat(AbstractDb): deal with sqlite3 logs on Android and Ios

parent 0f551221
......@@ -21,6 +21,10 @@
#include <TargetConditionals.h>
#endif // ifdef __APPLE__
#if defined(SOCI_ENABLED) && (TARGET_OS_IPHONE || defined(__ANDROID__))
#include <sqlite3.h>
#endif // if defined(SOCI_ENABLED) && (TARGET_OS_IPHONE || defined(__ANDROID__))
#include "abstract-db-p.h"
#include "logger/logger.h"
......@@ -30,19 +34,29 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
AbstractDb::AbstractDb (AbstractDbPrivate &p) : Object(p) {}
// Force static sqlite3 linking for IOS and Android.
#if defined(SOCI_ENABLED) && (TARGET_OS_IPHONE || defined(__ANDROID__))
// Force static sqlite3 linking for IOS and Android.
extern "C" void register_factory_sqlite3();
static void sqlite3Log (void *, int iErrCode, const char *zMsg) {
lInfo() << "[sqlite3][" << iErrCode << "]" << zMsg;
}
#endif // if defined(SOCI_ENABLED) && (TARGET_OS_IPHONE || defined(__ANDROID__))
AbstractDb::AbstractDb (AbstractDbPrivate &p) : Object(p) {}
bool AbstractDb::connect (Backend backend, const string &parameters) {
L_D();
#if defined(SOCI_ENABLED) && (TARGET_OS_IPHONE || defined(__ANDROID__))
if (backend == Sqlite3)
register_factory_sqlite3();
if (backend == Sqlite3) {
static bool registered = false;
if (!registered) {
registered = true;
register_factory_sqlite3();
sqlite3_config(SQLITE_CONFIG_LOG, sqlite3Log, nullptr);
}
}
#endif // if defined(SOCI_ENABLED) && (TARGET_OS_IPHONE || defined(__ANDROID__))
d->backend = backend;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment