当前位置: 首页 > news >正文

NanoLog起步笔记-7-log解压过程初探

nonolog起步笔记-6-log解压过程初探

  • 再看解压过程
  • 建立调试工程
    • 修改makefile
    • 添加新的launch项
  • 注:重新学习nanolog的README.md
    • Post-Execution Log Decompressor

下面我们尝试了解,解压的过程,是如何得到文件头部的meta信息的。

再看解压过程

./decompressor decompress /tmp/logFile
在这里插入图片描述如上图,发现,除了前两条有内容,其它的,其实是空的。
这里我们得到第一个猜想是,原始的binary log中,没有有效的消息总条数。所以,解析的程序,
将所有的可能的条目都解了一遍。这是因为,实际的应用中,因为每client(用户线程),实际一直在已经写满的circlebuffer中工作,不会有空白的。

也没有序号,因为时间戳,作为唯一的时间标识。

今天先这样,明天再继续。建一个新的工程之后,详细了解解压的过程。
目前,还没有找到meta是如何存入到最终的log中。只看到每record如何记录注册到meta中的logregistID

建立调试工程

修改makefile

可以有许多选择,这里我们还是基于 sample下的GNUmakefile,来进行。
./sample/GNUmakefile
因为我们现在的focus在解压,所以,我们不希望每次clean将上将做好的log文件删除。
所以,

clean:@rm -f *.o sampleApplication /tmp/logFile compressedLog

改为

clean:@rm -f *.o sampleApplication compressedLog

意外的收获,发现其中还有一个clean-all,这是很好,能解决昨天说的,有时无法下断的问题。
因为每次编译都是从runtime目录拷过来libNanoLog.a,如果本目录存在这个文件,将不会重编libNanoLog.a。

# Cleans up the NanoLog files as well
clean-all: clean@rm -f libNanoLog.a decompressor$(MAKE) clean-all -C $(NANOLOG_RUNTIME_DIR)

所以,可以将昨天的贴文中的tasks.json内容改为:
“make clean-all”,

	"tasks": [{"type": "shell","label": "make clean-all","command": "make","args": ["-f","GNUmakefile","clean"],"options": {"cwd": "${workspaceFolder}/sample"},"problemMatcher": ["$gcc"],"detail": "cleaning: make clean"},

添加新的launch项

.vscode/launch.json{"name": "C++ Launch decompressor","type": "cppdbg","request": "launch","program": "${workspaceFolder}/sample/decompressor","args": ["/tmp/logFile"],"environment": [{ "name": "config", "value": "Debug" }],"cwd": "${workspaceFolder}/sample","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}

这样做好分析,解压过程的准备。

注:重新学习nanolog的README.md

https://github.com/PlatformLab/NanoLog

在这里插入图片描述## Sample Applications

cd sample# Modify the application
nano main.ccmake clean-all
make
./sampleApplication
./decompressor decompress /tmp/logFile

Post-Execution Log Decompressor

The execution of the user application should generate a compressed, binary log file (default locations: ./compressedLog or /tmp/logFile). To make the log file human-readable, simply invoke the decompressor application with the log file.

./decompressor decompress ./compressedLog

After building the NanoLog library, the decompressor executable can be found in either the ./runtime directory (for C++17 NanoLog) or the user app directory (for Preprocessor NanoLog).

再向后是单元测试


http://www.mrgr.cn/news/79602.html

相关文章:

  • 【开源】A063—基于Spring Boot的农产品直卖平台的设计与实现
  • Vue3小兔鲜电商项目
  • 【人工智能基础08】卷积神经网络习题:卷积神经网络计算、图像填充、卷积的表达与设计
  • 【优选算法 位运算】位运算算法入门详解:位运算小专题
  • 分布式架构
  • 使用mmdeploy框架C++预测mask并绘制最小外接矩形
  • 排序算法(1):冒泡排序
  • STM32F103 FPGA进行通信方式
  • 第四十六篇 Vision Transformer论文翻译
  • 【开源】A065—基于SpringBoot的库存管理系统的设计与实现
  • java中的抽象类
  • Redis安装和Python练习(Windows11 + Python3.X + Pycharm社区版)
  • 人工智能大模型LLM开源资源汇总(持续更新)
  • 【光电倍增管】-打拿极 PMT
  • SpringBoot3整合Druid数据源
  • 配置新电脑设置的脚本
  • 嵌入式入门Day26
  • android NumberPicker隐藏分割线或修改颜色
  • android notification
  • Python 检验项目分析与历次报告比对