rv1126-external/minilogger
qiurui 1fcbea2c44 Init commit 2024-04-03 22:11:04 +08:00
..
cmake Init commit 2024-04-03 22:11:04 +08:00
include/minilogger Init commit 2024-04-03 22:11:04 +08:00
src Init commit 2024-04-03 22:11:04 +08:00
test Init commit 2024-04-03 22:11:04 +08:00
.editorconfig Init commit 2024-04-03 22:11:04 +08:00
.gitignore Init commit 2024-04-03 22:11:04 +08:00
CMakeLists.txt Init commit 2024-04-03 22:11:04 +08:00
LICENSE Init commit 2024-04-03 22:11:04 +08:00
README.md Init commit 2024-04-03 22:11:04 +08:00

README.md

minilogger

A small logger with backtrace in signal handler

Usage

  • build option

Enable the following compile options if you need backtrace

target_compile_options(mytarget PRIVATE -g -ggdb -gdwarf)
target_compile_options(mytarget PRIVATE -rdynamic -funwind-tables)

On ARM, you need an extra environment if you need backtrace

UNW_ARM_UNWIND_METHOD=1 ./mytarget

the output will like:

trace_cpp[12328]: trace_cpp version 1.1
trace_cpp[12328]: Aborting (signal 11) [./trace_cpp]
trace_cpp[12328]: ++++++++ backtrace ++++++++
trace_cpp[12328]: Frame #00: (signal_handler(int)+0x1c) [0x10d30]
trace_cpp[12328]: Frame #01: (sigset+0x14c) [0x10d30]
trace_cpp[12328]: Frame #02: (crash()+0x8) [0x10b14]
trace_cpp[12328]: Frame #03: (main+0x30) [0x109e0]
trace_cpp[12328]: Frame #04: (_fini+0xc) [0x109e0]
trace_cpp[12328]: +++++++++++++++++++++++++++

and also in syslog

# tail -9 /var/log/messages
Mar  6 14:40:46 Puma daemon.info trace_cpp[11042]: trace_cpp version 1.1
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: Aborting (signal 11) [./trace_cpp]
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: ++++++++ backtrace ++++++++
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: Frame #00: (signal_handler(int)+0x1c) [0x10d30]^M
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: Frame #01: (sigset+0x14c) [0x10d30]^M
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: Frame #02: (crash()+0x8) [0x10b14]^M
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: Frame #03: (main+0x30) [0x109e0]^M
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: Frame #04: (_fini+0xc) [0x109e0]^M
Mar  6 14:40:46 Puma daemon.err trace_cpp[11042]: +++++++++++++++++++++++++++