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).
再向后是单元测试