日志

一、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这种类型。

全部评论: 0

    写评论: