Split out of #34, which now covers only the ANSI color work.
CONFIG_ZSYS_LOG_INTERCEPT_ESP_LOG (opt-in, default n): deferred mode today only queues LOG_* (zsys) calls; ESP_LOG* traffic from ESP-IDF internals (wifi/BLE init storm) still hits UART synchronously, so a high-prio caller there blocks. When set, zsys_log_init() installs an esp_log_set_vprintf() hook that queues onto the log msgq with K_NO_WAIT -- same drop-counter path as zsys_log_msg_emit.
Constraints already known:
- ISR context must fall back to the default vprintf (
xPortInIsrContext()), since k_msgq_put is not ISR-safe.
- Panic mode must unhook so crash logs stay synchronous.
Open design question -- the reason this was split out. With IDF log v1 (the default in both 5.4 and 5.5), the esp_log_set_vprintf hook receives a line that is already fully formatted -- "I (123) wifi: msg\n", color escapes included. ESP_LOGx bakes the letter, timestamp and tag into the format string at compile time, so there are no separate level/tag arguments to recover. Filling a struct log_msg from it and running that back through zsys_log_format_msg() double-formats:
[12.345] <INF> esp: I (123) wifi: msg
Two ways out:
- Pass through verbatim -- flag the msg as pre-formatted; backends print
text as-is with no prefix. Interleaved styles in one stream, nothing mangled, ~15 lines.
- Parse level + tag out of the prefix and refill a real
log_msg, so intercepted lines look native. Uniform output, but the parser is coupled to IDF's format string and breaks under log v2 (CONFIG_LOG_VERSION_2, available in 5.5), which centralizes formatting inside esp_log() and hands the hook different input.
Pick one before implementing.
Split out of #34, which now covers only the ANSI color work.
CONFIG_ZSYS_LOG_INTERCEPT_ESP_LOG(opt-in, default n): deferred mode today only queuesLOG_*(zsys) calls;ESP_LOG*traffic from ESP-IDF internals (wifi/BLE init storm) still hits UART synchronously, so a high-prio caller there blocks. When set,zsys_log_init()installs anesp_log_set_vprintf()hook that queues onto the log msgq withK_NO_WAIT-- same drop-counter path aszsys_log_msg_emit.Constraints already known:
xPortInIsrContext()), sincek_msgq_putis not ISR-safe.Open design question -- the reason this was split out. With IDF log v1 (the default in both 5.4 and 5.5), the
esp_log_set_vprintfhook receives a line that is already fully formatted --"I (123) wifi: msg\n", color escapes included.ESP_LOGxbakes the letter, timestamp and tag into the format string at compile time, so there are no separate level/tag arguments to recover. Filling astruct log_msgfrom it and running that back throughzsys_log_format_msg()double-formats:Two ways out:
textas-is with no prefix. Interleaved styles in one stream, nothing mangled, ~15 lines.log_msg, so intercepted lines look native. Uniform output, but the parser is coupled to IDF's format string and breaks under log v2 (CONFIG_LOG_VERSION_2, available in 5.5), which centralizes formatting insideesp_log()and hands the hook different input.Pick one before implementing.