1 | //! WARNING: this is not part of the crate's public API and is subject to change at any time
|
2 |
|
3 | use crate::{Level, Metadata, Record};
|
4 | use std::fmt::Arguments;
|
5 | pub use std::option::Option;
|
6 | pub use std::{file, format_args, line, module_path, stringify};
|
7 |
|
8 | #[cfg (not(feature = "kv_unstable" ))]
|
9 | pub fn log(
|
10 | args: Arguments,
|
11 | level: Level,
|
12 | &(target, module_path, file): &(&str, &'static str, &'static str),
|
13 | line: u32,
|
14 | kvs: Option<&[(&str, &str)]>,
|
15 | ) {
|
16 | if kvs.is_some() {
|
17 | panic!(
|
18 | "key-value support is experimental and must be enabled using the `kv_unstable` feature"
|
19 | )
|
20 | }
|
21 |
|
22 | crate::logger().log(
|
23 | &Record::builder()
|
24 | .args(args)
|
25 | .level(level)
|
26 | .target(target)
|
27 | .module_path_static(Some(module_path))
|
28 | .file_static(Some(file))
|
29 | .line(Some(line))
|
30 | .build(),
|
31 | );
|
32 | }
|
33 |
|
34 | #[cfg (feature = "kv_unstable" )]
|
35 | pub fn log(
|
36 | args: Arguments,
|
37 | level: Level,
|
38 | &(target, module_path, file): &(&str, &'static str, &'static str),
|
39 | line: u32,
|
40 | kvs: Option<&[(&str, &dyn crate::kv::ToValue)]>,
|
41 | ) {
|
42 | crate::logger().log(
|
43 | &Record::builder()
|
44 | .args(args)
|
45 | .level(level)
|
46 | .target(target)
|
47 | .module_path_static(Some(module_path))
|
48 | .file_static(Some(file))
|
49 | .line(Some(line))
|
50 | .key_values(&kvs)
|
51 | .build(),
|
52 | );
|
53 | }
|
54 |
|
55 | pub fn enabled(level: Level, target: &str) -> bool {
|
56 | crate::logger().enabled(&Metadata::builder().level(level).target(target).build())
|
57 | }
|
58 | |