Skip to content

zsys/log: ANSI color output + optional ESP_LOG intercept for deferred mode #34

@swoisz

Description

@swoisz

Two related logging enhancements:

1. CONFIG_ZSYS_LOG_COLOR (bool, default y, depends on CONFIG_ZSYS_LOG_MODULE): esp_backend_put wraps the level indicator in VT100 codes — red ERR, yellow WRN, green INF, default DBG — for both the deferred (<ERR>) and sync (E) formats. zsys_log_format_msg gains a color flag (mirroring upstream's LOG_OUTPUT_FLAG_COLORS) so the backend decides. ~30 lines across log_backend_esp.c, log.c, Kconfig.

2. 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 formats into a struct log_msg and does k_msgq_put(..., K_NO_WAIT) on the log queue — same drop-counter path as zsys_log_msg_emit. ISR context must fall back to the default vprintf (xPortInIsrContext()), since k_msgq_put is not ISR-safe; panic mode unhooks so crash logs stay synchronous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions