diff options
author | drh <drh@noemail.net> | 2010-02-18 18:45:09 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-02-18 18:45:09 +0000 |
commit | 3f280701095c788a830a80927cc0af9ae9cfd036 (patch) | |
tree | 9aa692e812c44c2b080c825644807352b9afdffa /src/printf.c | |
parent | da730f6eb4e1df1b844b8c0cb0b68f3389a37960 (diff) | |
download | sqlite-3f280701095c788a830a80927cc0af9ae9cfd036.tar.gz sqlite-3f280701095c788a830a80927cc0af9ae9cfd036.zip |
Add a new, experimental logging interface designed to aid in debugging of
deeply embedded projects that use SQLite.
FossilOrigin-Name: 103321e37ae46eacfad4e127d13477ad5dd02bab
Diffstat (limited to 'src/printf.c')
-rw-r--r-- | src/printf.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/printf.c b/src/printf.c index fdd4793c3..2966946f9 100644 --- a/src/printf.c +++ b/src/printf.c @@ -939,6 +939,28 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ return z; } +/* +** Format and write a message to the log if logging is enabled. +*/ +void sqlite3_log(int iPriority, const char *zFormat, ...){ + void (*xLog)(void*, int, const char*); /* The global logger function */ + void *pLogArg; /* First argument to the logger */ + va_list ap; /* Vararg list */ + char *zMsg; /* Complete log message */ + + xLog = sqlite3GlobalConfig.xLog; + if( xLog ){ + va_start(ap, zFormat); + sqlite3BeginBenignMalloc(); + zMsg = sqlite3_vmprintf(zFormat, ap); + sqlite3EndBenignMalloc(); + va_end(ap); + pLogArg = sqlite3GlobalConfig.pLogArg; + xLog(pLogArg, iPriority, zMsg ? zMsg : zFormat); + sqlite3_free(zMsg); + } +} + #if defined(SQLITE_DEBUG) /* ** A version of printf() that understands %lld. Used for debugging. |