7#include "libxr_def.hpp"
13static Topic log_topic;
19#if LIBXR_PRINTF_BUFFER_SIZE > 0
20 void (*log_cb_fun)(
bool in_isr,
Topic,
RawData &log_data) =
27 if (LIBXR_LOG_OUTPUT_LEVEL >=
static_cast<uint8_t
>(log->level) &&
STDIO::write_ &&
57 auto ans = vsnprintf(data.
message,
sizeof(data.
message), fmt, args);
static Callback Create(FunType fun, ArgType arg)
static void PrintToTerminal(const LogData &data)
打印日志到终端 / Print log to terminal
static const char * LevelToString(LogLevel level)
将日志级别转换为字符串 / Convert log level to string
static void Init()
初始化日志主题 / Initialize the log topic
static void Publish(LogLevel level, const char *file, uint32_t line, const char *fmt,...)
发布一条日志 / Publish a log message
static const char * GetColor(LogLevel level)
根据日志级别获取显示颜色 / Get color code based on log level
表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.
原始数据封装类。 A class for encapsulating raw data.
void * addr_
数据存储地址。 The storage address of the data.
static int Printf(const char *fmt,...)
Prints a formatted string to the write port (like printf).
static WritePort * write_
Write port instance. 写入端口。
static uint32_t GetTime()
获取当前系统时间(毫秒) Gets the current system time in milliseconds
主题(Topic)管理类 / Topic management class
void Publish(Data &data)
发布数据 Publishes data
static Topic CreateTopic(const char *name, Domain *domain=nullptr, bool cache=false, bool check_length=true)
创建一个新的主题 Creates a new topic
void RegisterCallback(Callback &cb)
注册回调函数 Registers a callback function
bool Writable()
判断端口是否可写。 Checks whether the port is writable.
constexpr const char * LIBXR_FONT_STR[]
ANSI escape sequences for font color / ANSI转义序列 - 字体颜色
constexpr const char * LIBXR_FORMAT_STR[]
ANSI escape sequences for text format / ANSI转义序列 - 文本格式
LogLevel
日志级别枚举 / Log level enumeration
@ XR_LOG_LEVEL_INFO
一般信息 / Informational message
@ XR_LOG_LEVEL_DEBUG
调试信息 / Debug message
@ XR_LOG_LEVEL_WARN
警告信息 / Warning message
@ XR_LOG_LEVEL_ERROR
错误信息 / Error message
@ XR_LOG_LEVEL_PASS
通过信息 / Pass message
日志数据结构体 / Log data structure
uint32_t line
行号 / Line number
const char * file
文件名指针 / Source file name pointer
LogLevel level
日志级别 / Log level
MillisecondTimestamp timestamp
时间戳 / Timestamp
char message[XR_LOG_MESSAGE_MAX_LEN]
日志消息内容 / Log message content