Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is lit a type-o or is lite too long?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's short for literal, not lite.

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 {
Expand Down
11 changes: 11 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down