This is my implementation of a multithreading C++ library for logging.
Operating system | Status |
---|---|
Linux | |
Windows |
To use the logger, do the following:
- Add the logger to your CMake-configured project:
add_subdirectory(<path/to/cpp_logger>)
- Include this header into your C++ file:
#include <logger.h>
- Initialize and start the logger:
auto log = Logger::create("test.log", "log");
log->start();
- Write logs:
log->write("Log entry categorized as INFO");
log->write("Error message", Logger::MsgType::ERROR);
log->write("Some warning", Logger::MsgType::WARNING);
The logger will create a test.log
file under ./log/\<date\>/
directory and then write something like:
[18:52:10:826] INFO: Log entry categorized as INFO
[18:52:10:827] ERROR: Error message
[18:52:10:827] WARNING: Some warning
The project is configured with CMake. The building process may vary on different platforms and environments, though it follows the same pattern:
cd path/to/this/project; mkdir build; cd build # Make a build directory.
cmake .. # Generate a Makefile.
make # Build the program.
If build is successful, the library will appear in the path/to/this/project/lib
directory.
Tests are managed with Catch and are by default excluded from ALL targets. It means if you want to build them, run the commands from the "Build" section but replace the last command with:
make logger_tests
If build is successful, an executable will appear in the path/to/this/project/bin
directory.
This project is distributed under MIT License which means you can freely use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the "Software" as described in the LICENSE file.