diff options
| -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(); |
