Skip to content

Commit

Permalink
Merge pull request #416 from chewing/rust/tracing
Browse files Browse the repository at this point in the history
refactor: enable verbose tracing for Debug profile
  • Loading branch information
kanru authored Dec 31, 2023
2 parents e8ad8de + 3e7e715 commit 2ffde72
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 13 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ option(USE_VALGRIND "Use valgrind when testing" true)
option(WITH_RUST "Use rust implemented internals (experimental)" false)
if (WITH_RUST)
add_subdirectory(cmake/corrosion)
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing FEATURES capi)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing FEATURES capi test-tracing)
else()
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing FEATURES capi)
endif()
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing-tools)
add_compile_definitions(WITH_RUST)
endif()
Expand Down
162 changes: 154 additions & 8 deletions Cargo.lock

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

13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ edition = "2021"
include = ["src/**/*.rs", "Cargo.toml", "AUTHORS", "COPYING", "NEWS"]

[dependencies]
bytemuck = { version = "1.13.1", features = ["derive"] }
bytemuck = { version = "1.14.0", features = ["derive"] }
directories = "5.0.0"
indexmap = "2.0.0"
indexmap = "2.1.0"
riff = "2.0.0"
rusqlite = "0.30.0"
thiserror = "1.0.0"
tracing = "0.1.37"
tracing = { version = "0.1.40", features = [
"max_level_trace",
"release_max_level_warn",
] }
tracing-subscriber = { version = "0.3.18", features = [
"env-filter",
], optional = true }

[target.'cfg(windows)'.dependencies]
rusqlite = { version = "0.30.0", features = ["bundled"] }
Expand All @@ -27,6 +33,7 @@ crate-type = ["lib", "staticlib"]
[features]
default = []
capi = ["cbindgen"]
test-tracing = ["tracing-subscriber"]

[build-dependencies]
# https://github.com/mozilla/cbindgen/issues/891
Expand Down
3 changes: 2 additions & 1 deletion src/capi/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@ pub extern "C" fn chewing_set_logger(
logger: extern "C" fn(data: *mut c_void, level: c_int, fmt: *const c_char, arg: ...),
data: *mut c_void,
) {
// let _ = tracing_subscriber::fmt::try_init();
#[cfg(all(feature = "test-tracing", debug_assertions))]
let _ = tracing_subscriber::fmt::try_init();
}

#[tracing::instrument(skip(ctx), ret)]
Expand Down

0 comments on commit 2ffde72

Please sign in to comment.