| 141 | */ |
| 142 | template <Level Lvl, typename... Args> |
| 143 | __always_inline auto Log(etl::format_string<Args...> fmt, Args&&... args) |
| 144 | -> void { |
| 145 | if constexpr (Lvl < kMinLevel) { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | LogEntry entry{}; |
| 150 | entry.seq = log_seq.fetch_add(1, std::memory_order_relaxed); |
| 151 | entry.core_id = cpu_io::GetCurrentCoreId(); |
| 152 | entry.level = Lvl; |
| 153 | auto* end = etl::format_to_n(entry.msg, sizeof(entry.msg) - 1, fmt, |
| 154 | static_cast<Args&&>(args)...); |
| 155 | *end = '\0'; |
| 156 | |
| 157 | if (!log_queue.push(entry)) { |
| 158 | // 队列满:尝试排空后重试一次 |
| 159 | TryDrain(); |
| 160 | if (!log_queue.push(entry)) { |
| 161 | dropped_count.fetch_add(1, std::memory_order_relaxed); |
| 162 | return; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | TryDrain(); |
| 167 | } |
| 168 | |
| 169 | } // namespace detail |
| 170 |
nothing calls this directly
no test coverage detected