|
SimpleKernel 1.17.0
|
Classes | |
| struct | LogEntry |
| 存储于 MPMC 队列中的日志条目 More... | |
Enumerations | |
| enum class | Level : uint8_t { kDebug = 0 , kInfo = 1 , kWarn = 2 , kErr = 3 } |
| 日志级别 More... | |
Functions | |
| __always_inline auto | PutStr (const char *s) -> void |
| 通过 etl_putchar 输出字符串(空指针安全) | |
| auto | TryDrain () -> void |
| 将队列中所有条目输出至串口 | |
| template<Level Lvl, typename... Args> | |
| __always_inline auto | Log (etl::format_string< Args... > fmt, Args &&... args) -> void |
| 核心实现:格式化消息并入队,随后尝试排空 | |
Variables | |
| constexpr auto | kMinLevel |
| 编译期最低日志级别 | |
| constexpr const char * | kLevelLabel [] |
| 日志级别标签(定宽,对齐输出) | |
| constexpr const char * | kLevelColor [] |
| 日志级别对应的颜色(按 Level 枚举索引) | |
| mpmc_queue::MPMCQueue< LogEntry, 256 > | log_queue |
| 全局日志队列(64 KB 静态内存,constexpr 构造) | |
| std::atomic< uint64_t > | log_seq {0} |
| 用于跨核心排序的单调递增序列计数器 | |
| std::atomic_flag | drain_flag = ATOMIC_FLAG_INIT |
| 单消费者排空保护(非阻塞 try-lock) | |
| std::atomic< uint64_t > | dropped_count {0} |
| 队列满时丢弃的条目计数 | |
ANSI 转义码 | |
| constexpr auto | kReset = "\033[0m" |
| constexpr auto | kRed = "\033[31m" |
| constexpr auto | kGreen = "\033[32m" |
| constexpr auto | kYellow = "\033[33m" |
| constexpr auto | kCyan = "\033[36m" |
|
strong |
| __always_inline auto klog::detail::Log | ( | etl::format_string< Args... > | fmt, |
| Args &&... | args | ||
| ) | -> void |
核心实现:格式化消息并入队,随后尝试排空
| Lvl | 编译期日志级别,低于 kMinLevel 时整个函数被编译器消除 |
| Args | 可变格式化参数类型 |
Definition at line 143 of file kernel_log.hpp.

| __always_inline auto klog::detail::PutStr | ( | const char * | s | ) | -> void |
通过 etl_putchar 输出字符串(空指针安全)
Definition at line 82 of file kernel_log.hpp.


|
inline |
将队列中所有条目输出至串口
使用 atomic_flag 实现非阻塞 try-lock,同一时刻仅一个核心执行排空, 其他核心直接返回,等待下次调用时再排空。
Definition at line 98 of file kernel_log.hpp.


|
inline |
单消费者排空保护(非阻塞 try-lock)
Definition at line 76 of file kernel_log.hpp.
|
inline |
|
inlineconstexpr |
Definition at line 25 of file kernel_log.hpp.
|
inlineconstexpr |
Definition at line 23 of file kernel_log.hpp.
|
inlineconstexpr |
|
inlineconstexpr |
日志级别标签(定宽,对齐输出)
Definition at line 41 of file kernel_log.hpp.
|
inlineconstexpr |
|
inlineconstexpr |
Definition at line 22 of file kernel_log.hpp.
|
inlineconstexpr |
Definition at line 21 of file kernel_log.hpp.
|
inlineconstexpr |
Definition at line 24 of file kernel_log.hpp.
|
inline |
全局日志队列(64 KB 静态内存,constexpr 构造)
Definition at line 70 of file kernel_log.hpp.
|
inline |