C++ logger with logging levels (standard output)
- Set desired log level
- Set desired log tag
- Include
minilogger.h - Print messages for desired log level
Include and declare the logger where you want with these three lines:
#define ___LOG_LEVEL
#define LOG_TAG "TEST_TAG"
#include "minilogger.h"Where the different levels of log can be (ordered from highest to lowest information shown):
___LOG_DEBUG--> Shows DEBUG, INFO, WARNING and ERROR___LOG_INFO--> Shows INFO, WARNING and ERROR___LOG_WARNING--> Shows WARNING and ERROR___LOG_ERROR--> Show ERROR
Print desired info in each level using:
LOGD("Debug message")LOGI("Info message")LOGW("Warning message")LOGE("Error message")
Thanks to iostream it is possible to concatenate data of different types and implicitly convert to string:
LOGD("my_text" << 10 << true);If you want to deactivate the logger, only comment the line where the level of the logger is defined:
//#define ___LOG_LEVEL
#define LOG_TAG "TEST_TAG"
#include "minilogger.h"mkdir build && cd build
cmake ..
make -j4
make install
# From BUILD_PATH
./samples/cpp_basic/cpp_basic