一、protobuf中的tlog
存储日志的文件叫logs.pb,是个protobuf文件。以下是一条日志的格式。
message tlog { int64 timestamp = 1; int32 type = 2; string aplt_id = 3; string task_id = 4; string device_id = 5; string msg = 6; };
timestamp是指示日志产生时间,一般用time(nullptr)生成。
type是该日志类型。
type | 方向 | 描述 |
logtype_aplt_task | 机器人->我 | 执行(小程序)任务过程中产生的日志。 |
logtype_iot_event | 机器人->我 | iot设备产生的事件。像门铃按下 |
logtype_nlp_resp | 机器人->我 | nlp模型返回的应答。 |
logtype_center_chat | 我->机器人 | 用户在center的“聊天”编辑框提问的消息。 |
logtype_speech_recognition | 我->机器人 | 语音识别出来的结果。此时用户是用说的。 |
logtype_warn | 机器人->我 | 运行过程中产生的警告日志信息。 |
aplt、id、device_id只在logtype_aplt_task时有意义,其它类型时,值都是空。aplt是小程序id、id是小程序任务id,device_id是当该任务操作的是一个蓝牙设备时,该蓝牙设备的硬件id。
二、合块显示
执行一个任务期间,会产生多条日志,在显示时,为方便用户查看,希望把这些日志合成一个“块”。目前支持合块的,只logtype_aplt_task这种类型。