|
OmniStacksStaticModules 2.0.0
|
Classes | |
| struct | ApiName |
| 接口名强类型。 语义:调用方必须显式构造 ApiName,避免把任意字符串误当接口名。 More... | |
| struct | LogText |
| 接口输入/输出文本强类型。 语义:与 ApiName 一样显式构造,参数顺序在编译期被类型约束。 More... | |
Enumerations | |
| enum class | ApiStatus { ok , failed } |
| 接口调用结果状态。 More... | |
| enum class | LogError { invalid_path , backend_unavailable } |
| 可恢复的日志初始化错误。 More... | |
Functions | |
| std::expected< std::monostate, LogError > | init (const std::filesystem::path &log_path="log/interface.log") |
| 初始化 bqlog TextFileAppender(可重复调用;路径变化会重建后端)。 | |
| std::size_t | cleanup_old_logs (const std::filesystem::path &log_path, int months_back=3) |
| 删除超过保留期的接口日志与每日 trace 日志。 | |
| void | set_enabled (bool enabled) |
| 启用/禁用接口记录(内存与文件同时生效)。 | |
| bool | enabled () |
| 当前是否启用接口记录。 | |
| void | record (ApiName api, LogText input, LogText output, ApiStatus status) |
| 记录一次接口调用。 | |
| std::vector< std::string > | recent () |
| 取出最近 <= kMaxLines 条记录(最旧在前)。 | |
| std::size_t | count () |
| 当前环形缓冲条数(<= kMaxLines)。 | |
| void | clear () |
| 清空内存环形缓冲(不动 bqlog 文件)。 | |
| std::filesystem::path | log_path () |
| 当前配置的日志路径。 | |
| template<std::invocable< std::string_view > Visitor> | |
| void | for_each_recent (Visitor &&visitor) |
| 在锁内逐条访问环形缓冲(函数对象设计)。 | |
| std::string_view | status_name (ApiStatus status) noexcept |
| 状态枚举到可读名称(供日志/测试使用)。 | |
| std::string_view | log_error_message (LogError error) noexcept |
| LogError 到可读消息(供 CLI / 测试使用)。 | |
| std::string | now_string () |
| 当前时间字符串(本地时间,秒级精度)。 | |
Variables | |
| constexpr std::size_t | kMaxLines = 1000 |
| 环形缓冲最大记录条数(= 1000)。 | |
| constexpr std::string_view | kDeveloperWebsite = "https://suchaharcan.github.io/" |
| 开发者网站水印;每次初始化 bqlog 与 CLI 调用日志都会写出。 | |
| std::mutex | g_mutex |
| 保护下列全部可变状态。 | |
| std::deque< std::string > | g_lines |
| 最近调用记录;队首最旧。 | |
| std::optional< bq::log > | g_logger |
| 可选 bqlog 文件后端。 | |
| std::filesystem::path | g_log_path |
| 当前后端日志基准路径。 | |
| bool | g_initialized = false |
| bqlog 是否已成功初始化。 | |
| bool | g_recording_enabled = true |
| Alfred 配置控制的全局日志开关。 | |
|
exportstrong |
接口调用结果状态。
| Enumerator | |
|---|---|
| ok | 调用成功 |
| failed | 调用失败(错误已记录在 output 文本中) |
Definition at line 35 of file InterfaceLog.cppm.
|
exportstrong |
可恢复的日志初始化错误。
| Enumerator | |
|---|---|
| invalid_path | 日志路径为空 |
| backend_unavailable | bqlog 后端初始化失败(环形缓冲仍可用) |
Definition at line 41 of file InterfaceLog.cppm.
|
export |
删除超过保留期的接口日志与每日 trace 日志。
| log_path | 当前接口日志基准路径(通常为 log/interface.log) |
| months_back | 保留月数,默认 3 |
Definition at line 202 of file InterfaceLog.cppm.
|
export |
清空内存环形缓冲(不动 bqlog 文件)。
Definition at line 303 of file InterfaceLog.cppm.
|
export |
当前环形缓冲条数(<= kMaxLines)。
Definition at line 298 of file InterfaceLog.cppm.
|
export |
当前是否启用接口记录。
Definition at line 288 of file InterfaceLog.cppm.
|
export |
在锁内逐条访问环形缓冲(函数对象设计)。
| visitor | 满足 std::invocable<std::string_view> 的可调用对象 |
Definition at line 314 of file InterfaceLog.cppm.
|
export |
初始化 bqlog TextFileAppender(可重复调用;路径变化会重建后端)。
| log_path | 文本日志路径,默认 log/interface.log |
Definition at line 155 of file InterfaceLog.cppm.
|
exportnoexcept |
LogError 到可读消息(供 CLI / 测试使用)。
Definition at line 332 of file InterfaceLog.cppm.
|
export |
当前配置的日志路径。
Definition at line 308 of file InterfaceLog.cppm.
| std::string interface_log::now_string | ( | ) |
当前时间字符串(本地时间,秒级精度)。
Definition at line 147 of file InterfaceLog.cppm.
|
export |
取出最近 <= kMaxLines 条记录(最旧在前)。
Definition at line 293 of file InterfaceLog.cppm.
记录一次接口调用。
| api | 接口名(强类型) |
| input | 输入摘要 |
| output | 输出摘要(失败时为错误信息) |
| status | 调用状态 |
Definition at line 257 of file InterfaceLog.cppm.
|
export |
启用/禁用接口记录(内存与文件同时生效)。
Definition at line 282 of file InterfaceLog.cppm.
|
exportnoexcept |
状态枚举到可读名称(供日志/测试使用)。
Definition at line 321 of file InterfaceLog.cppm.
| bool interface_log::g_initialized = false |
bqlog 是否已成功初始化。
Definition at line 140 of file InterfaceLog.cppm.
| std::deque<std::string> interface_log::g_lines |
最近调用记录;队首最旧。
Definition at line 137 of file InterfaceLog.cppm.
| std::filesystem::path interface_log::g_log_path |
当前后端日志基准路径。
Definition at line 139 of file InterfaceLog.cppm.
| std::optional<bq::log> interface_log::g_logger |
可选 bqlog 文件后端。
Definition at line 138 of file InterfaceLog.cppm.
| std::mutex interface_log::g_mutex |
保护下列全部可变状态。
Definition at line 136 of file InterfaceLog.cppm.
| bool interface_log::g_recording_enabled = true |
Alfred 配置控制的全局日志开关。
Definition at line 141 of file InterfaceLog.cppm.
|
inlineconstexprexport |
开发者网站水印;每次初始化 bqlog 与 CLI 调用日志都会写出。
Definition at line 32 of file InterfaceLog.cppm.
|
inlineconstexprexport |
环形缓冲最大记录条数(= 1000)。
Definition at line 29 of file InterfaceLog.cppm.