diff options
Diffstat (limited to '')
-rw-r--r-- | third_party/rust/jsparagus-json-log/.cargo-checksum.json | 1 | ||||
-rw-r--r-- | third_party/rust/jsparagus-json-log/Cargo.toml | 13 | ||||
-rw-r--r-- | third_party/rust/jsparagus-json-log/src/lib.rs | 41 |
3 files changed, 55 insertions, 0 deletions
diff --git a/third_party/rust/jsparagus-json-log/.cargo-checksum.json b/third_party/rust/jsparagus-json-log/.cargo-checksum.json new file mode 100644 index 0000000000..68d2763206 --- /dev/null +++ b/third_party/rust/jsparagus-json-log/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9f2d19883ad7a40debdac46726fd7709e53aba7b8a23d7843d085df44c0d6f2f","src/lib.rs":"09352799b74833de10a95ce1097fb0d1a3f3474468f61dc9adeb58705508e632"},"package":null}
\ No newline at end of file diff --git a/third_party/rust/jsparagus-json-log/Cargo.toml b/third_party/rust/jsparagus-json-log/Cargo.toml new file mode 100644 index 0000000000..151bd9d17c --- /dev/null +++ b/third_party/rust/jsparagus-json-log/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "jsparagus-json-log" +version = "0.1.0" +authors = ["The jsparagus Project Developers"] +edition = "2018" +license = "MIT/Apache-2.0" + +[dependencies] +log = { version = "0.4.0", features = ["max_level_debug", "release_max_level_warn"], optional = true } +serde_json = { version = "1.0", optional = true } + +[features] +logging = ["log", "serde_json"] diff --git a/third_party/rust/jsparagus-json-log/src/lib.rs b/third_party/rust/jsparagus-json-log/src/lib.rs new file mode 100644 index 0000000000..ed818566e5 --- /dev/null +++ b/third_party/rust/jsparagus-json-log/src/lib.rs @@ -0,0 +1,41 @@ +//! Provides a debug/trace output with json format. +//! This is disabled by default, and can be enabled by "logging" feature. + +#[cfg(feature = "logging")] +pub use log::{debug, trace}; +#[cfg(feature = "logging")] +pub use serde_json::json; + +#[cfg(not(feature = "logging"))] +#[macro_export] +macro_rules! json_debug { + ($($t:tt)*) => {}; +} + +#[cfg(feature = "logging")] +#[macro_export(local_inner_macros)] +macro_rules! json_debug { + ($($t:tt)*) => { + debug!( + "{}", + json!($($t)*) + ); + }; +} + +#[cfg(not(feature = "logging"))] +#[macro_export] +macro_rules! json_trace { + ($($t:tt)*) => {}; +} + +#[cfg(feature = "logging")] +#[macro_export(local_inner_macros)] +macro_rules! json_trace { + ($($t:tt)*) => { + trace!( + "{}", + json!($($t)*) + ); + }; +} |