1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Add a new, experimental logging interface designed to aid in debugging of

deeply embedded projects that use SQLite.

FossilOrigin-Name: 103321e37ae46eacfad4e127d13477ad5dd02bab
This commit is contained in:
drh
2010-02-18 18:45:09 +00:00
parent da730f6eb4
commit 3f28070109
7 changed files with 73 additions and 13 deletions

View File

@@ -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.