drop one header into your project and get colored, leveled, formatted logging.
#include "cpplog/log.hpp"
cpplog::info("server started on port {}", 8080);
cpplog::warn("memory at {}%", 87);
cpplog::error("connection failed: {}", "timeout");
cpplog::debug("loaded {} entries", count);output in terminal (color-coded by level):
[INFO ] 14:02:11 server started on port 8080
[WARN ] 14:02:11 memory at 87%
[ERROR] 14:02:11 connection failed: timeout
[DEBUG] 14:02:11 loaded 42 entries
copy include/cpplog/log.hpp into your project.
or with CMake FetchContent:
include(FetchContent)
FetchContent_Declare(cpplog
GIT_REPOSITORY https://github.com/ligumas/cpplog.git
GIT_TAG main
)
FetchContent_MakeAvailable(cpplog)
target_link_libraries(your_target cpplog)#include "cpplog/log.hpp"
cpplog::debug("x = {}", x);
cpplog::info("ready");
cpplog::warn("high load: {}%", load);
cpplog::error("failed: {}", msg);
cpplog::set_level(cpplog::Level::WARN); // filter below WARN
cpplog::set_color(false); // disable ANSI (e.g. piped output)
cpplog::set_file("app.log"); // also write to file- single header, zero dependencies
- C++17, Linux/Windows/macOS
{}placeholder formatting- log levels: DEBUG INFO WARN ERROR
- colored terminal output (ANSI)
- optional file output
- thread-safe
cmake -B build && cmake --build build
./build/testsLicense: MIT