chore(logging): trim firmware logs and remove runtime diagnostics scaffolding

This commit is contained in:
admin
2026-03-02 03:26:03 +08:00
parent d83111191d
commit 6d82ccae3e
20 changed files with 81 additions and 630 deletions

View File

@@ -87,22 +87,6 @@ static void voice_marker_image_generation_record_success(const char *prompt,
portEXIT_CRITICAL(&s_marker_image_gen_lock);
}
static void voice_log_text_preview(const char *stage, const char *text) {
if (stage == NULL || text == NULL || text[0] == '\0') {
return;
}
size_t len = strlen(text);
const int preview = 240;
ESP_LOGI(TAG,
"[stage] %s: len=%u text=%.*s%s",
stage,
(unsigned)len,
preview,
text,
(len > (size_t)preview) ? "..." : "");
}
static bool voice_is_space_char(char c) {
return isspace((unsigned char)c) != 0;
}
@@ -243,10 +227,6 @@ static void voice_try_preview_marker_png(const voice_image_generation_task_arg_t
preview_err,
sizeof(preview_err));
if (preview_rc == ESP_OK) {
ESP_LOGI(TAG,
"[stage] marker_image_preview_ok: dialog_id=%s png_bytes=%u",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)png_len);
return;
}
@@ -255,7 +235,7 @@ static void voice_try_preview_marker_png(const voice_image_generation_task_arg_t
}
ESP_LOGW(TAG,
"[stage] marker_image_preview_failed: dialog_id=%s rc=0x%x msg=%s",
"marker_image_preview_failed: dialog_id=%s rc=0x%x msg=%s",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)preview_rc,
preview_err[0] != '\0' ? preview_err : "preview failed");
@@ -277,11 +257,6 @@ static esp_err_t voice_submit_marker_generated_image(const voice_image_generatio
uint8_t *raster = NULL;
size_t raster_len = 0;
char decode_err[128] = {0};
ESP_LOGI(TAG,
"[stage] marker_image_print_decode_start: dialog_id=%s request_id=%s png_bytes=%u",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
result->request_id[0] != '\0' ? result->request_id : "-",
(unsigned)result->png_len);
esp_err_t decode_rc = raster_tools_convert_png_to_raster_384(result->png,
result->png_len,
true,
@@ -299,19 +274,13 @@ static esp_err_t voice_submit_marker_generated_image(const voice_image_generatio
err_len,
decode_err[0] != '\0' ? decode_err : "decode generated image failed");
ESP_LOGW(TAG,
"[stage] marker_image_print_decode_failed: dialog_id=%s rc=0x%x msg=%s",
"marker_image_print_decode_failed: dialog_id=%s rc=0x%x msg=%s",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)decode_rc,
err != NULL && err[0] != '\0' ? err : "decode generated image failed");
return decode_rc;
}
ESP_LOGI(TAG,
"[stage] marker_image_print_decode_done: dialog_id=%s raster_size=%ux%u raster_bytes=%u",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)raster_width,
(unsigned)raster_height,
(unsigned)raster_len);
uint32_t job_id = 0;
char submit_err[128] = {0};
@@ -332,16 +301,11 @@ static esp_err_t voice_submit_marker_generated_image(const voice_image_generatio
err_len,
submit_err[0] != '\0' ? submit_err : "submit print job failed");
ESP_LOGW(TAG,
"[stage] marker_image_print_submit_failed: dialog_id=%s rc=0x%x msg=%s",
"marker_image_print_submit_failed: dialog_id=%s rc=0x%x msg=%s",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)submit_rc,
err != NULL && err[0] != '\0' ? err : "submit print job failed");
} else {
ESP_LOGI(TAG,
"[stage] marker_image_print_submit_ok: dialog_id=%s request_id=%s job_id=%u",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
result->request_id[0] != '\0' ? result->request_id : "-",
(unsigned)job_id);
}
free(raster);
@@ -370,21 +334,10 @@ static void voice_image_generation_task(void *arg) {
printer_status_poll_pause_token_t status_poll_pause_token = 0;
char gen_err[160] = {0};
ESP_LOGI(TAG,
"[stage] marker_image_gen_start: dialog_id=%s prompt_len=%u",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)strlen(task_arg->prompt));
status_poll_pause_token = printer_protocol_status_poll_pause_acquire();
esp_err_t rc = image_generation_generate_png(&req, &result, gen_err, sizeof(gen_err));
printer_protocol_status_poll_pause_release(&status_poll_pause_token);
if (rc == ESP_OK) {
ESP_LOGI(TAG,
"[stage] marker_image_gen_done: dialog_id=%s request_id=%s size=%ux%u png_bytes=%u",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
result.request_id[0] != '\0' ? result.request_id : "-",
(unsigned)result.width,
(unsigned)result.height,
(unsigned)result.png_len);
char submit_err[160] = {0};
esp_err_t submit_rc = voice_submit_marker_generated_image(task_arg,
@@ -397,14 +350,14 @@ static void voice_image_generation_task(void *arg) {
voice_now_ms());
} else {
ESP_LOGW(TAG,
"[stage] marker_image_print_failed: dialog_id=%s rc=0x%x msg=%s",
"marker_image_print_failed: dialog_id=%s rc=0x%x msg=%s",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)submit_rc,
submit_err[0] != '\0' ? submit_err : "marker image print failed");
}
} else {
ESP_LOGW(TAG,
"[stage] marker_image_gen_failed: dialog_id=%s rc=0x%x msg=%s",
"marker_image_gen_failed: dialog_id=%s rc=0x%x msg=%s",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
(unsigned)rc,
gen_err[0] != '\0' ? gen_err : "image generation failed");
@@ -425,30 +378,22 @@ static void voice_schedule_marker_image_generation(const char *prompt, const cha
size_t prompt_len = strlen(prompt);
if (prompt_len > VOICE_IMAGE_MARKER_PROMPT_MAX_LEN) {
ESP_LOGW(TAG,
"[stage] marker_image_gen_skip: prompt too long, len=%u",
"marker_image_gen_skip: prompt too long, len=%u",
(unsigned)prompt_len);
return;
}
uint32_t repeat_remain_ms = 0;
if (!voice_marker_image_generation_try_acquire(prompt,
dialog_id,
voice_now_ms(),
&repeat_remain_ms)) {
if (repeat_remain_ms > 0) {
ESP_LOGI(TAG,
"[stage] marker_image_gen_skip: duplicate prompt suppressed, remain_ms=%u",
(unsigned)repeat_remain_ms);
} else {
ESP_LOGI(TAG, "[stage] marker_image_gen_skip: previous marker task running");
}
NULL)) {
return;
}
voice_image_generation_task_arg_t *task_arg =
(voice_image_generation_task_arg_t *)calloc(1, sizeof(*task_arg));
if (task_arg == NULL) {
ESP_LOGW(TAG, "[stage] marker_image_gen_skip: no memory for task arg");
ESP_LOGW(TAG, "marker_image_gen_skip: no memory for task arg");
voice_marker_image_generation_release();
return;
}
@@ -465,16 +410,11 @@ static void voice_schedule_marker_image_generation(const char *prompt, const cha
VOICE_IMAGE_GEN_TASK_PRIO,
NULL);
if (ok != pdPASS) {
ESP_LOGW(TAG, "[stage] marker_image_gen_skip: create task failed");
ESP_LOGW(TAG, "marker_image_gen_skip: create task failed");
voice_marker_image_generation_release();
free(task_arg);
return;
}
ESP_LOGI(TAG,
"[stage] marker_image_gen_queued: dialog_id=%s prompt=%s",
task_arg->dialog_id[0] != '\0' ? task_arg->dialog_id : "-",
task_arg->prompt);
}
void voice_marker_try_trigger_image_generation(const char *dialog_id, const char *final_text) {
@@ -497,17 +437,10 @@ void voice_marker_try_trigger_image_generation(const char *dialog_id, const char
templated_prompt,
sizeof(templated_prompt));
if (templated_prompt[0] == '\0') {
ESP_LOGW(TAG, "[stage] marker_image_gen_skip: build prompt failed");
ESP_LOGW(TAG, "marker_image_gen_skip: build prompt failed");
return;
}
ESP_LOGI(TAG,
"[stage] marker_image_gen_detected: first_sentence=%s",
first_sentence);
ESP_LOGI(TAG,
"[stage] marker_image_gen_subject: keyword=%s",
marker_subject);
voice_log_text_preview("marker_image_gen_prompt_templated", templated_prompt);
voice_schedule_marker_image_generation(templated_prompt, dialog_id);
}