Skip to content

Commit 7609d18

Browse files
committed
refactor(sys): add logger and format code
1 parent 1777767 commit 7609d18

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

taos-ws-sys/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ crate-type = ["cdylib", "staticlib"]
1212
anyhow = "1"
1313
bytes = "1.1.0"
1414
cargo_metadata = "0.18.1"
15+
ctor = "0.2.9"
1516
futures = { version = "0.3", features = ["executor"] }
1617
once_cell = "1.20.2"
1718
pretty_env_logger = "0.5.0"
@@ -20,14 +21,12 @@ taos-error = { path = "../taos-error" }
2021
taos-query = { path = "../taos-query" }
2122
taos-ws = { path = "../taos-ws" }
2223
tracing = { version = "0.1", features = ["log"] }
24+
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
2325

2426
[build-dependencies]
2527
cbindgen = "0.27.0"
2628
syn = { version = "2.0.91", features = ["full", "visit"] }
2729

28-
[dev-dependencies]
29-
pretty_env_logger = "0.5.0"
30-
3130
[features]
3231
default = ["rustls", "rustls-ring-crypto-provider"]
3332

taos-ws-sys/src/native/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(unused_variables)]
22

33
use std::ffi::{c_char, c_int, c_void, CStr};
4-
use std::ptr::{null, null_mut};
54
use std::sync::RwLock;
65

76
use error::{set_err_and_get_code, Error};
@@ -38,7 +37,7 @@ pub unsafe extern "C" fn taos_connect(
3837
Ok(taos) => Box::into_raw(Box::new(taos)) as _,
3938
Err(err) => {
4039
set_err_and_get_code(err);
41-
null_mut()
40+
std::ptr::null_mut()
4241
}
4342
}
4443
}
@@ -162,7 +161,7 @@ pub unsafe extern "C" fn taos_options(
162161
pub extern "C" fn taos_data_type(r#type: c_int) -> *const c_char {
163162
match Ty::from_u8_option(r#type as _) {
164163
Some(ty) => ty.tsdb_name(),
165-
None => null(),
164+
None => std::ptr::null(),
166165
}
167166
}
168167

taos-ws-sys/src/ws/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl From<&Field> for WS_FIELD {
425425
pub struct ROW {
426426
/// Data is used to hold the row data
427427
data: Vec<*const c_void>,
428-
/// current row to get
428+
/// Current row to get
429429
current_row: usize,
430430
}
431431

taos-ws-sys/tests/Makefile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
DEBUG_PATH=../../target/debug
2-
FLAGS=-I${DEBUG_PATH} -L${DEBUG_PATH} -Wl,-rpath=${DEBUG_PATH} -ltaosws
1+
DEBUG_PATH := ../../target/debug
2+
LINK_FLAGS := -I$(DEBUG_PATH) -L$(DEBUG_PATH) -ltaosws
3+
4+
OS := $(shell uname)
5+
6+
ifeq ($(OS), Linux)
7+
export LD_LIBRARY_PATH=$(DEBUG_PATH)
8+
else ifeq ($(OS), Darwin)
9+
export DYLD_LIBRARY_PATH=$(DEBUG_PATH)
10+
else
11+
$(error Unsupported OS: $(OS))
12+
endif
313

414
test_native:
5-
gcc -g test_native.c ${FLAGS} -o ${DEBUG_PATH}/test_native
6-
./${DEBUG_PATH}/test_native
15+
gcc -g test_native.c $(LINK_FLAGS) -o $(DEBUG_PATH)/test_native
16+
./$(DEBUG_PATH)/test_native

taos-ws-sys/tests/test_native.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
int main()
55
{
6-
init_log();
7-
86
int code = taos_options(TSDB_OPTION_LOCALE, NULL, "group.id", "10s", "enable.auto.commit", "false", NULL);
97
assert(code == 0);
108

0 commit comments

Comments
 (0)