diff --git a/Cargo.toml b/Cargo.toml index 19a3b5f..8f2c05d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple-log" -version = "1.6.0" +version = "1.7.0" authors = ["baoyachi "] description = "A simple log. It's really simple use" edition = "2018" @@ -20,6 +20,10 @@ once_cell = "1.15.0" serde = { version = "1.0.145", features = ["derive"] } is_debug = "1.0.1" convert_case = "0.6.0" +ctor = { version = "0.2.2", optional = true } + +[features] +debug = ["ctor"] [dev-dependencies] serde_json = "1" diff --git a/src/lib.rs b/src/lib.rs index 2849ecd..001aac9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -682,3 +682,9 @@ pub mod log_level { } } } + +#[cfg(feature = "debug")] +#[ctor::ctor] +fn init_log() { + quick!(); +}