mirror of
https://gitee.com/openharmony/third_party_rust_log
synced 2024-11-22 23:29:49 +00:00
Merge pull request #366 from sfackler/lit-code-size
Add a separate path for messages with no format arguments
This commit is contained in:
commit
4597769adc
19
src/lib.rs
19
src/lib.rs
@ -1420,6 +1420,25 @@ pub fn __private_api_log(
|
||||
);
|
||||
}
|
||||
|
||||
// WARNING: this is not part of the crate's public API and is subject to change at any time
|
||||
#[doc(hidden)]
|
||||
pub fn __private_api_log_lit(
|
||||
message: &str,
|
||||
level: Level,
|
||||
&(target, module_path, file, line): &(&str, &'static str, &'static str, u32),
|
||||
) {
|
||||
logger().log(
|
||||
&Record::builder()
|
||||
.args(format_args!("{}", message))
|
||||
.level(level)
|
||||
.target(target)
|
||||
.module_path_static(Some(module_path))
|
||||
.file_static(Some(file))
|
||||
.line(Some(line))
|
||||
.build(),
|
||||
);
|
||||
}
|
||||
|
||||
// WARNING: this is not part of the crate's public API and is subject to change at any time
|
||||
#[doc(hidden)]
|
||||
pub fn __private_api_enabled(level: Level, target: &str) -> bool {
|
||||
|
@ -47,6 +47,17 @@ macro_rules! log {
|
||||
#[doc(hidden)]
|
||||
macro_rules! log_impl {
|
||||
// End of macro input
|
||||
(target: $target:expr, $lvl:expr, ($message:expr)) => {
|
||||
let lvl = $lvl;
|
||||
if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() {
|
||||
$crate::__private_api_log_lit(
|
||||
$message,
|
||||
lvl,
|
||||
&($target, __log_module_path!(), __log_file!(), __log_line!()),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
(target: $target:expr, $lvl:expr, ($($arg:expr),*)) => {
|
||||
let lvl = $lvl;
|
||||
if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() {
|
||||
|
Loading…
Reference in New Issue
Block a user