Skip to content

Commit 1d7fb16

Browse files
authored
Merge pull request #1712 from tursodatabase/libsql-tracing
add libsql_enable_tracing to the libsql
2 parents cece90a + 3853145 commit 1d7fb16

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/c/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ bytes = "1.5.0"
1515
lazy_static = "1.4.0"
1616
tokio = { version = "1.29.1", features = [ "rt-multi-thread" ] }
1717
hyper-rustls = { version = "0.25", features = ["webpki-roots"]}
18+
tracing = "0.1.40"
19+
tracing-subscriber = "0.3.18"
1820

1921
[target.'cfg(not(any(target_os = "ios", target_os = "android")))'.dependencies]
2022
libsql = { path = "../../libsql", features = ["encryption"] }

bindings/c/include/libsql.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ typedef struct {
6161
extern "C" {
6262
#endif // __cplusplus
6363

64+
int libsql_enable_internal_tracing(void);
65+
6466
int libsql_sync(libsql_database_t db, const char **out_err_msg);
6567

6668
int libsql_sync2(libsql_database_t db, replicated *out_replicated, const char **out_err_msg);

bindings/c/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ unsafe fn set_err_msg(msg: String, output: *mut *const std::ffi::c_char) {
3131
}
3232
}
3333

34+
#[no_mangle]
35+
pub unsafe extern "C" fn libsql_enable_internal_tracing() -> std::ffi::c_int {
36+
if tracing_subscriber::fmt::try_init().is_ok() {
37+
1
38+
} else {
39+
0
40+
}
41+
}
42+
3443
#[no_mangle]
3544
pub unsafe extern "C" fn libsql_sync(
3645
db: libsql_database_t,

0 commit comments

Comments
 (0)