Skip to content

zsys/log: optional ESP_LOG intercept for deferred mode #56

Description

@swoisz

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:

  1. 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.
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions