From f8cac17823a123e08b69607a7e321b5b0a3123e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Thu, 8 Dec 2022 17:23:11 +0000 Subject: [PATCH] Add custom error logger --- c_src/sqlite3_nif.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/c_src/sqlite3_nif.c b/c_src/sqlite3_nif.c index 174c4f79..c7d41f64 100644 --- a/c_src/sqlite3_nif.c +++ b/c_src/sqlite3_nif.c @@ -904,6 +904,10 @@ statement_type_destructor(ErlNifEnv* env, void* arg) } } +void errorLogCallback(void *pArg, int iErrCode, const char *zMsg){ + fprintf(stderr, "ERRORLOGGER: (%d) %s\n", iErrCode, zMsg); +} + static int on_load(ErlNifEnv* env, void** priv, ERL_NIF_TERM info) { @@ -921,6 +925,7 @@ on_load(ErlNifEnv* env, void** priv, ERL_NIF_TERM info) sqlite3_config(SQLITE_CONFIG_GETMALLOC, &default_alloc_methods); sqlite3_config(SQLITE_CONFIG_MALLOC, &methods); + sqlite3_config(SQLITE_CONFIG_LOG, errorLogCallback, &env); connection_type = enif_open_resource_type( env,