diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-05-14 22:01:45 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-05-15 00:21:24 +0200 |
| commit | e86ce263a9f5fdd7c09758f489d80c564dbb7fc5 (patch) | |
| tree | e1dc31700e3707c3c054f2b5981c1ab875e5e126 /src | |
| parent | bc52bdcd51328a38bb80cd65ef9af72466be2bcf (diff) | |
| download | PROJ-e86ce263a9f5fdd7c09758f489d80c564dbb7fc5.tar.gz PROJ-e86ce263a9f5fdd7c09758f489d80c564dbb7fc5.zip | |
Add SQLite3 debug logging if PROJ_LOG_SQLITE3 env var is defined
Diffstat (limited to 'src')
| -rw-r--r-- | src/sqlite3_utils.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sqlite3_utils.cpp b/src/sqlite3_utils.cpp index 7006674f..84bbb2ce 100644 --- a/src/sqlite3_utils.cpp +++ b/src/sqlite3_utils.cpp @@ -133,8 +133,25 @@ static int VFSCustomAccess(sqlite3_vfs *vfs, const char *zName, int flags, // --------------------------------------------------------------------------- +// SQLite3 logging infrastructure +static void projSqlite3LogCallback(void *, int iErrCode, const char *zMsg) { + fprintf(stderr, "SQLite3 message: (code %d) %s\n", iErrCode, zMsg); +} + std::unique_ptr<SQLite3VFS> SQLite3VFS::create(bool fakeSync, bool fakeLock, bool skipStatJournalAndWAL) { + + // Install SQLite3 logger if PROJ_LOG_SQLITE3 env var is defined + struct InstallSqliteLogger { + InstallSqliteLogger() { + if (getenv("PROJ_LOG_SQLITE3") != nullptr) { + sqlite3_config(SQLITE_CONFIG_LOG, projSqlite3LogCallback, + nullptr); + } + } + }; + static InstallSqliteLogger installSqliteLogger; + // Call to sqlite3_initialize() is normally not needed, except for // people building SQLite3 with -DSQLITE_OMIT_AUTOINIT sqlite3_initialize(); |
