Skip to content

Commit

Permalink
Merge pull request #1712 from tursodatabase/libsql-tracing
Browse files Browse the repository at this point in the history
add libsql_enable_tracing to the libsql
  • Loading branch information
sivukhin authored Aug 31, 2024
2 parents cece90a + 3853145 commit 1d7fb16
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions bindings/c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 2 additions & 0 deletions bindings/c/include/libsql.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions bindings/c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1d7fb16

Please sign in to comment.