diff --git a/Cargo.lock b/Cargo.lock index 722e06d46b..55f4323a93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5366,6 +5366,8 @@ dependencies = [ "lazy_static", "libsql", "tokio", + "tracing", + "tracing-subscriber", ] [[package]] diff --git a/bindings/c/Cargo.toml b/bindings/c/Cargo.toml index e25e393327..8e293d69d6 100644 --- a/bindings/c/Cargo.toml +++ b/bindings/c/Cargo.toml @@ -15,6 +15,8 @@ bytes = "1.5.0" lazy_static = "1.4.0" tokio = { version = "1.29.1", features = [ "rt-multi-thread" ] } hyper-rustls = { version = "0.25", features = ["webpki-roots"]} +tracing = "0.1.40" +tracing-subscriber = "0.3.18" [target.'cfg(not(any(target_os = "ios", target_os = "android")))'.dependencies] libsql = { path = "../../libsql", features = ["encryption"] } diff --git a/bindings/c/include/libsql.h b/bindings/c/include/libsql.h index 7fdfb4b3c0..971d2eb9aa 100644 --- a/bindings/c/include/libsql.h +++ b/bindings/c/include/libsql.h @@ -61,6 +61,8 @@ typedef struct { extern "C" { #endif // __cplusplus +int libsql_enable_internal_tracing(void); + int libsql_sync(libsql_database_t db, const char **out_err_msg); int libsql_sync2(libsql_database_t db, replicated *out_replicated, const char **out_err_msg); diff --git a/bindings/c/src/lib.rs b/bindings/c/src/lib.rs index 6cb1dc096e..8e80816ff0 100644 --- a/bindings/c/src/lib.rs +++ b/bindings/c/src/lib.rs @@ -31,6 +31,15 @@ unsafe fn set_err_msg(msg: String, output: *mut *const std::ffi::c_char) { } } +#[no_mangle] +pub unsafe extern "C" fn libsql_enable_internal_tracing() -> std::ffi::c_int { + if tracing_subscriber::fmt::try_init().is_ok() { + 1 + } else { + 0 + } +} + #[no_mangle] pub unsafe extern "C" fn libsql_sync( db: libsql_database_t,