Files
MeowOS-SDK/sdk/include/meow_ui_log.h
T
MeowOS f44e3bc6d0 Add 'sdk/' from commit '2e7561d74f75de05dd7fb362f203f600afb451d7'
git-subtree-dir: sdk
git-subtree-mainline: 17a972d46f
git-subtree-split: 2e7561d74f
2026-09-01 21:08:40 +08:00

33 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* meow_ui_log.h — SDK 应用日志(§9,统一日志 API,M2.51 最小可用版)。
*
* 原 meow_ui.h 拆分的一部分(log 模块)。app 只需一行 meow_log();SDK 管「写哪/怎么写/过滤/降级/上限」。
*/
#ifndef MEOW_UI_LOG_H
#define MEOW_UI_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================ */
/* §9 应用日志(统一日志 API,M2.51 最小可用版) */
/* ============================================================ */
/* app 只需一行 meow_log();SDK 管「写哪/怎么写/过滤/降级/上限」:
* - 路径:<MEOW_LOG_DIR>/<启动时间>_<pid>.log(MEOW_LOG_DIR 已含包名分层 logs/<包名>)
* (目录不存在 mkdir -p,按 app 分目录),每次启动=新文件,同一次启动内 O_APPEND 追加;
* - 级别过滤:lvl < meow_log_get_level() 丢弃;默认 MEOW_LOG_INFO;
* - 格式:<monotonic_ms> [<app_id>] <LEVEL> message\n;
* - 上限:单文件 ≥2MB 自动开新文件追加 _<n>;每 App 总量 ≥50MB 按期删最旧,防撑爆卡;
* - 无卡/写失败降级 stderr,不阻塞 app 不崩;线程安全。
* 注意:MEOW_LOG_APP 由 launcher 注入;未注入时默认 app_id="app"。 */
typedef enum { MEOW_LOG_DEBUG=0, MEOW_LOG_INFO, MEOW_LOG_WARN, MEOW_LOG_ERROR } meow_log_level;
void meow_log(meow_log_level lvl, const char *fmt, ...); /* app 一行调用,写到按 app 分离日志 */
void meow_log_set_level(meow_log_level lvl); /* 可选:app 设本 app 级别;默认 MEOW_LOG_INFO */
meow_log_level meow_log_get_level(void);
#ifdef __cplusplus
}
#endif
#endif /* MEOW_UI_LOG_H */