Avoids overwriting log level and target if they've already been set
This commit corrects an issue what could occur if cipher_log_level and/or cipher_log are set prior to activating sqlcipher, i.e. if those pragmas are called before PRAGMA key or sqlite3_key. In that case the specific requested log settings would be ovewritten by different defaults.
This commit is contained in:
parent
addaa4c047
commit
c50f84f591
@ -205,15 +205,24 @@ void sqlcipher_activate() {
|
||||
sqlcipher_static_mutex[i] = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
|
||||
}
|
||||
#ifndef SQLCIPHER_OMIT_DEFAULT_LOGGING
|
||||
/* when sqlcipher is first activated, set a default log target and level of WARN. Use the "device log"
|
||||
for android (logcat) or apple (console). Use stderr on all other platforms. */
|
||||
/* when sqlcipher is first activated, set a default log target and level of WARN if the
|
||||
logging settings have not yet been initialized. Use the "device log" for
|
||||
android (logcat) or apple (console). Use stderr on all other platforms. */
|
||||
if(!sqlcipher_log_set) {
|
||||
sqlcipher_log_level = SQLCIPHER_LOG_WARN;
|
||||
|
||||
/* set log level if it is different than the uninitalized default value of NONE */
|
||||
if(sqlcipher_log_level == SQLCIPHER_LOG_NONE) {
|
||||
sqlcipher_log_level = SQLCIPHER_LOG_WARN;
|
||||
}
|
||||
|
||||
/* set the default file or device if neither is already set */
|
||||
if(sqlcipher_log_device == 0 && sqlcipher_log_file == NULL) {
|
||||
#if defined(__ANDROID__) || defined(__APPLE_)
|
||||
sqlcipher_log_device = 1;
|
||||
sqlcipher_log_device = 1;
|
||||
#else
|
||||
sqlcipher_log_file = stderr;
|
||||
sqlcipher_log_file = stderr;
|
||||
#endif
|
||||
}
|
||||
sqlcipher_log_set = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user