This project implements a C++ logging library designed to handle exceptions, stack traces, and message filtering. The logger is flexible, supporting multiple output options such as the console and files, while filtering messages based on severity levels.
- Modular Logger Interface:
- Abstract
Loggerclass with implementations likeFileLoggerandConsoleLogger. - Supports RAII for resource management.
- Abstract
- Log Filtering:
- Five severity levels: OFF, DEBUG, INFO, WARNING, ERROR.
- Customizable with
set_logging_level()for dynamic filtering.
- Exception Logging:
fatal_logged_exceptionclass, derived fromstd::exception, logs detailed errors including file name and line number.- Example log:
ERROR: fatal_logged_exception: main.cpp - 27: TEST.
- Stacktrace Support:
- Integrated with Backward-Cpp to provide detailed stack trace information, including function names, code lines, and file paths.
- Signal Handling:
- Custom
signal_handlercaptures unexpected program signals (e.g., segmentation faults) and logs details along with the stack trace.
- Custom
To build successfully, the libdwarf and libelf libraries are needed, be sure to have them installed and on the path CPLUS_INCLUDE_PATH and LIBRARY_PATH.
git clone https://github.com/ZT-715/cpp-logger
cd cpp-logger/
git submodule init
git submodule update
make build
./main.o 1
Potential improvements include:
- Resolving memory allocation issues in signal handling.
- Reducing global variable dependency to align with RAII principles.
