libcoreso_demo
v2.0.0
Published
对齐 C++ 日志打印规范,方便查看对应日志。
Downloads
1
Readme
Node online 日志库
对齐 C++ 日志打印规范,方便查看对应日志。
安装
tnpm install @tencent/wx-node-onlinelog --save
使用
# import 语法,二选一
import nodelog from "@tencent/wx-node-onlinelog";
# requre 语法,二选一
const nodelog = require("@tencent/wx-node-onlinelog");
// 模板方法
let res = nodelog.OpenLogFull("mmbizdendiwu", 16425, 3,"/home/qspace/log",true, true);
if(res == 0){
// 注册成功
nodelog.LogInfo("hello world")
nodelog.LogErr("hello world")
nodelog.LogDebug("hello world")
}
模板方法参数说明:
int OpenLogFull(const char *sModuleName, const int id,
const int iLogLevel, const char *sPath,
bool bIsAttachModuleInfoShm, bool bIsOpenNetLog);
- sModuleName: 当前项目的模块名,比如 mmbizwxadevdoc
- id: CMDB 的 id,找运维负责人询问,也可以随便写一个,不重要
- iLogLevel: 默认为 3
- sPath: 日志打印的路径名
- bIsAttachModuleInfoShm: 是否搭在对应的模块下,统一写 true
- bIsOpenNetLog: 开启网络日志,统一写 true
实际打印日志如下:
<3> <ossattragent(24243,24304,0,0,0)> 16:15:11 268 [soacallgraphapi.cpp:ReportSoaCallGraph:178] need_report_edge_info_size <= 0
<2> <connagent(39579,39585)> 16:15:11 273 ERROR:micromsg/connagent/skfsm.cpp:OnTimeout:2277 timeout m_iState 5
<2> <connagent(39579,39585)> 16:15:11 273 Error:micromsg/connagent/sknetwork.cpp:Process:1205: Svrkit STATE_FSM_ERROR == iRet
<3> <ossattragent(24243,24304,0,0,0)> 16:15:11 288 [soacallgraphapi.cpp:ReportSoaCallGraph:178] need_report_edge_info_size <= 0
<3> <ossattragent(24243,24304,0,0,0)> 16:15:11 288 [soacallgraphapi.cpp:ReportSoaCallGraph:178] need_report_edge_info_size <= 0
<3> <ossattragent(24228,81789,0,0,0)> 16:15:11 303 debug: SvrkitClientCallWrap zone 0 uin 0 ip 10.57.150.160 17001 ret 0 headret 0
<3> <ossattragent(24243,24304,0,0,0)> 16:15:11 308 [soacallgraphapi.cpp:ReportSoaCallGraph:178] need_report_edge_info_size <= 0
node_boilerplate 接入文档
该库已经接入 node_boilerplate/@core 中,只需要下载 wx-node-onlinelog 包即可。
# 更新 core
cd node/@core
git pull origin master
# 下载 npm 包
tnpm install @tencent/wx-node-onlinelog --save
线上日志查询
详情参考:https://git.code.oa.com/wxg-td/netlog/wikis/mmlog%E6%97%A5%E5%BF%97%E6%9F%A5%E8%AF%A2%E5%B7%A5%E5%85%B7