Skip to content

Commit 49afad5

Browse files
committed
Added interface to sqlite3_log().
1 parent 8dbb78f commit 49afad5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/sqlite.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ module sqlite
216216
public :: sqlite3_libversion
217217
public :: sqlite3_libversion_
218218
public :: sqlite3_libversion_number
219+
public :: sqlite3_log
219220
public :: sqlite3_open
220221
public :: sqlite3_open_
221222
public :: sqlite3_prepare
@@ -606,6 +607,14 @@ subroutine sqlite3_free(ptr) bind(c, name='sqlite3_free')
606607
type(c_ptr), intent(in), value :: ptr
607608
end subroutine sqlite3_free
608609

610+
! void sqlite3_log(int iErrCode, const char *zFormat, ...)
611+
subroutine sqlite3_log(ierr_code, zformat) bind(c, name='sqlite3_log')
612+
import :: c_char, c_int
613+
implicit none
614+
integer(kind=c_int), intent(in), value :: ierr_code
615+
character(kind=c_char), intent(in) :: zformat
616+
end subroutine sqlite3_log
617+
609618
! void sqlite3_str_append(sqlite3_str *str, const char *zIn, int N)
610619
subroutine sqlite3_str_append(str, zin, n) bind(c, name='slqite3_str_append')
611620
import :: c_char, c_int, c_ptr

test/test_sqlite.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ program test_sqlite
8888
use, intrinsic :: iso_c_binding
8989
use :: sqlite
9090
use :: callbacks
91+
implicit none (type, external)
9192
character(len=*), parameter :: DB_FILE = 'test.db'
9293
character(len=*), parameter :: DB_TABLE = 'test_table'
9394

@@ -111,6 +112,9 @@ program test_sqlite
111112
rc = sqlite3_open(DB_FILE, db)
112113
if (rc /= SQLITE_OK) stop 'sqlite3_open(): failed'
113114

115+
! Testing logging.
116+
call sqlite3_log(1, 'TEST LOG' // c_null_char)
117+
114118
! Enable WAL mode.
115119
print '("Turning WAL mode on ...")'
116120
rc = journal_mode_wal(db)

0 commit comments

Comments
 (0)