• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2025 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 #![no_std]
16 
17 #[doc(hidden)]
18 pub mod __private {
19     pub use pw_log_backend_macro::{_pw_log_backend, _pw_logf_backend};
20 
21     pub use console;
22     pub use embedded_io;
23     use pw_log_backend_api::LogLevel;
24 
log_level_tag(level: LogLevel) -> &'static str25     pub const fn log_level_tag(level: LogLevel) -> &'static str {
26         match level {
27             LogLevel::Debug => "DBG",
28             LogLevel::Info => "INF",
29             LogLevel::Warn => "WRN",
30             LogLevel::Error => "ERR",
31             LogLevel::Critical => "CRT",
32             LogLevel::Fatal => "FTL",
33         }
34     }
35 }
36 
37 // Implement the `pw_log` backend API.
38 #[macro_export]
39 macro_rules! pw_log_backend {
40   ($log_level:expr, $format_string:literal $(, $args:expr)* $(,)?) => {{
41     use $crate::__private as __pw_log_backend_crate;
42     $crate::__private::_pw_log_backend!($log_level, $format_string, $($args),*);
43   }};
44 }
45 
46 #[macro_export]
47 macro_rules! pw_logf_backend {
48   ($log_level:expr, $format_string:literal $(, $args:expr)* $(,)?) => {{
49     use $crate::__private as __pw_log_backend_crate;
50     $crate::__private::_pw_logf_backend!($log_level, $format_string, $($args),*);
51   }};
52 }
53