From 1b6a04ca5504955c571d1c97504fb45ea0befee4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 8 Jan 2024 01:21:28 +0400 Subject: Initial vendor packages Signed-off-by: Valentin Popov --- vendor/log/src/__private_api.rs | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 vendor/log/src/__private_api.rs (limited to 'vendor/log/src/__private_api.rs') diff --git a/vendor/log/src/__private_api.rs b/vendor/log/src/__private_api.rs new file mode 100644 index 0000000..4018077 --- /dev/null +++ b/vendor/log/src/__private_api.rs @@ -0,0 +1,57 @@ +//! WARNING: this is not part of the crate's public API and is subject to change at any time + +use crate::{Level, Metadata, Record}; +use std::fmt::Arguments; +pub use std::option::Option; +pub use std::{file, format_args, line, module_path, stringify}; + +#[cfg(not(feature = "kv_unstable"))] +pub fn log( + args: Arguments, + level: Level, + &(target, module_path, file): &(&str, &'static str, &'static str), + line: u32, + kvs: Option<&[(&str, &str)]>, +) { + if kvs.is_some() { + panic!( + "key-value support is experimental and must be enabled using the `kv_unstable` feature" + ) + } + + crate::logger().log( + &Record::builder() + .args(args) + .level(level) + .target(target) + .module_path_static(Some(module_path)) + .file_static(Some(file)) + .line(Some(line)) + .build(), + ); +} + +#[cfg(feature = "kv_unstable")] +pub fn log( + args: Arguments, + level: Level, + &(target, module_path, file): &(&str, &'static str, &'static str), + line: u32, + kvs: Option<&[(&str, &dyn crate::kv::ToValue)]>, +) { + crate::logger().log( + &Record::builder() + .args(args) + .level(level) + .target(target) + .module_path_static(Some(module_path)) + .file_static(Some(file)) + .line(Some(line)) + .key_values(&kvs) + .build(), + ); +} + +pub fn enabled(level: Level, target: &str) -> bool { + crate::logger().enabled(&Metadata::builder().level(level).target(target).build()) +} -- cgit v1.2.3