static void _zf_log_write_imp( const zf_log_spec *log, const src_location *const src, const mem_block *const mem, const int lvl, const char *const tag, const char *const fmt, va_list va) { zf_log_message msg; char buf[ZF_LOG_BUF_SZ]; const unsigned mask = log->output->mask; msg.lvl = lvl; msg.tag = tag; g_buffer_cb(&msg, buf); if (ZF_LOG_PUT_CTX & mask) { put_ctx(&msg); } if (ZF_LOG_PUT_TAG & mask) { put_tag(&msg, tag); } if (0 != src && ZF_LOG_PUT_SRC & mask) { put_src(&msg, src); } if (ZF_LOG_PUT_MSG & mask) { put_msg(&msg, fmt, va); } log->output->callback(&msg, log->output->arg); if (0 != mem && ZF_LOG_PUT_MSG & mask) { output_mem(log, &msg, mem); } }
static void _bt_log_write_imp( const bt_log_spec *log, const src_location *const src, const mem_block *const mem, const int lvl, const char *const tag, const char *const fmt, va_list va) { bt_log_message msg; char buf[BT_LOG_BUF_SZ]; const unsigned mask = log->output->mask; msg.lvl = lvl; msg.tag = tag; g_buffer_cb(&msg, buf); const char *rst_color_p = bt_common_color_reset(); const char *rst_color_e = rst_color_p + strlen(rst_color_p); const char *color_p = ""; const char *color_e = color_p; switch (lvl) { case BT_LOG_INFO: color_p = bt_common_color_fg_blue(); color_e = color_p + strlen(color_p); break; case BT_LOG_WARN: color_p = bt_common_color_fg_yellow(); color_e = color_p + strlen(color_p); break; case BT_LOG_ERROR: case BT_LOG_FATAL: color_p = bt_common_color_fg_red(); color_e = color_p + strlen(color_p); break; default: break; } msg.p = put_stringn(color_p, color_e, msg.p, msg.e); if (BT_LOG_PUT_CTX & mask) { put_ctx(&msg); } if (BT_LOG_PUT_TAG & mask) { put_tag(&msg, tag); } if (0 != src && BT_LOG_PUT_SRC & mask) { put_src(&msg, src); } if (BT_LOG_PUT_MSG & mask) { put_msg(&msg, fmt, va); } msg.p = put_stringn(rst_color_p, rst_color_e, msg.p, msg.e); log->output->callback(&msg, log->output->arg); if (0 != mem && BT_LOG_PUT_MSG & mask) { output_mem(log, &msg, mem); } }