Index: System.Data.SQLite/LINQ/SQLiteFactory_Linq.cs ================================================================== --- System.Data.SQLite/LINQ/SQLiteFactory_Linq.cs +++ System.Data.SQLite/LINQ/SQLiteFactory_Linq.cs @@ -41,11 +41,11 @@ { #if (SQLITE_STANDARD || USE_INTEROP_DLL || PLATFORM_COMPACTFRAMEWORK) && PRELOAD_NATIVE_LIBRARY UnsafeNativeMethods.Initialize(); #endif - SQLiteLog.Initialize(typeof(SQLiteFactory).Name); + SQLiteLog.Initialize(typeof(SQLiteFactory).Name, false); string version = #if NET_40 || NET_45 || NET_451 || NET_452 || NET_46 || NET_461 || NET_462 || NET_47 || NET_471 || NET_472 "4.0.0.0"; #else Index: System.Data.SQLite/SQLiteConnection.cs ================================================================== --- System.Data.SQLite/SQLiteConnection.cs +++ System.Data.SQLite/SQLiteConnection.cs @@ -1764,11 +1764,11 @@ #if (SQLITE_STANDARD || USE_INTEROP_DLL || PLATFORM_COMPACTFRAMEWORK) && PRELOAD_NATIVE_LIBRARY UnsafeNativeMethods.Initialize(); #endif - SQLiteLog.Initialize(typeof(SQLiteConnection).Name); + SQLiteLog.Initialize(typeof(SQLiteConnection).Name, false); #if !PLATFORM_COMPACTFRAMEWORK && !INTEROP_LEGACY_CLOSE && SQLITE_STANDARD // // NOTE: Check if the sqlite3_close_v2() native API should be available // to use. This must be done dynamically because the delegate set Index: System.Data.SQLite/SQLiteLog.cs ================================================================== --- System.Data.SQLite/SQLiteLog.cs +++ System.Data.SQLite/SQLiteLog.cs @@ -103,11 +103,10 @@ /// private static SQLiteLogEventHandler _defaultHandler; /////////////////////////////////////////////////////////////////////// -#if !USE_INTEROP_DLL || !INTEROP_LOG /// /// The log callback passed to native SQLite engine. This must live /// as long as the SQLite library has a pointer to it. /// private static SQLiteLogCallback _callback; @@ -116,16 +115,15 @@ /// /// The base SQLite object to interop with. /// private static SQLiteBase _sql; -#endif /////////////////////////////////////////////////////////////////////// /// - /// The number of times that the + /// The number of times that the /// has been called when the logging subystem was actually eligible /// to be initialized (i.e. without the "No_SQLiteLog" environment /// variable being set). /// private static int _initializeCallCount; @@ -150,11 +148,30 @@ /// /// Initializes the SQLite logging facilities. /// public static void Initialize() { - Initialize(null); + Initialize(false); + } + + /////////////////////////////////////////////////////////////////////// + + /// + /// Initializes the SQLite logging facilities. + /// + /// + /// When this parameter is non-zero, the native logging callback + /// provided by the SQLite interop assembly will not be used, even + /// if it is available. When the native logging callback provided + /// by the SQLite interop assembly is not available, the value of + /// this parameter is ignored. + /// + public static void Initialize( + bool managedOnly + ) + { + Initialize(null, managedOnly); } /////////////////////////////////////////////////////////////////////// /// @@ -161,13 +178,21 @@ /// Initializes the SQLite logging facilities. /// /// /// The name of the managed class that called this method. This /// parameter may be null. + /// + /// + /// When this parameter is non-zero, the native logging callback + /// provided by the SQLite interop assembly will not be used, even + /// if it is available. When the native logging callback provided + /// by the SQLite interop assembly is not available, the value of + /// this parameter is ignored. /// internal static void Initialize( - string className + string className, + bool managedOnly ) { // // NOTE: See if the logging subsystem has been totally disabled. // If so, do nothing. @@ -258,56 +283,61 @@ #endif /////////////////////////////////////////////////////////////// #if USE_INTEROP_DLL && INTEROP_LOG - // - // NOTE: Attempt to setup interop assembly log callback. - // This may fail, e.g. if the SQLite core library - // has somehow been initialized. An exception will - // be raised in that case. - // - SQLiteErrorCode rc = SQLite3.ConfigureLogForInterop( - className); - - if (rc != SQLiteErrorCode.Ok) - { - throw new SQLiteException(rc, - "Failed to configure interop assembly logging."); - } -#else - // - // NOTE: Create an instance of the SQLite wrapper class. - // - if (_sql == null) - { - _sql = new SQLite3( - SQLiteDateFormats.Default, DateTimeKind.Unspecified, - null, IntPtr.Zero, null, false); - } - - // - // NOTE: Create a single "global" (i.e. per-process) callback - // to register with SQLite. This callback will pass the - // event on to any registered handler. We only want to - // do this once. - // - if (_callback == null) - { - _callback = new SQLiteLogCallback(LogCallback); - - SQLiteErrorCode rc = _sql.SetLogCallback(_callback); - - if (rc != SQLiteErrorCode.Ok) - { - _callback = null; /* UNDO */ - - throw new SQLiteException(rc, - "Failed to configure managed assembly logging."); - } - } -#endif + if (!managedOnly) + { + // + // NOTE: Attempt to setup interop assembly log callback. + // This may fail, e.g. if the SQLite core library + // has somehow been initialized. An exception will + // be raised in that case. + // + SQLiteErrorCode rc = SQLite3.ConfigureLogForInterop( + className); + + if (rc != SQLiteErrorCode.Ok) + { + throw new SQLiteException(rc, + "Failed to configure interop assembly logging."); + } + } + else +#endif + { + // + // NOTE: Create an instance of the SQLite wrapper class. + // + if (_sql == null) + { + _sql = new SQLite3(SQLiteDateFormats.Default, + DateTimeKind.Unspecified, null, IntPtr.Zero, + null, false); + } + + // + // NOTE: Create single global (i.e. per-process) callback + // to register with SQLite. The callback will pass + // the event on to any registered handler. We only + // want to do this once. + // + if (_callback == null) + { + _callback = new SQLiteLogCallback(LogCallback); + + SQLiteErrorCode rc = _sql.SetLogCallback(_callback); + + if (rc != SQLiteErrorCode.Ok) + { + _callback = null; /* UNDO */ + + throw new SQLiteException(rc, + "Failed to configure managed assembly logging."); + } + } + } /////////////////////////////////////////////////////////////// // // NOTE: Logging is enabled by default unless the configuration