LogIt is a C++ logging library with:
- a fixed front-end API (
LOG(...), component registration, runtime log-level control), - pluggable backends selected at CMake configure time,
- component-level filtering.
- CMake
>= 3.30 - C++17 compiler
Optional dependencies are only required for optional backends (see below).
Default build (stdout backend, object library):
cmake -S . -B build
cmake --build build --config ReleaseLOGIT_BUILD_SHARED_LIB controls the target type:
OFF(default): buildsLogItas anOBJECTlibraryON: buildsLogItas aSHAREDlibrary
Example shared-library build:
cmake -S . -B build -DLOGIT_BUILD_SHARED_LIB=ON
cmake --build build --config Release- This project currently has no
install()or package export rules. - With
LOGIT_BUILD_SHARED_LIB=OFF,LogItis an object-library target intended for use inside the same CMake build. - With
LOGIT_BUILD_SHARED_LIB=ON,LogItis produced as a shared library.
Available CMake options:
LOGIT_BACKEND_STDOUTLOG # default ON
LOGIT_BACKEND_BOOSTLOG # default OFF
LOGIT_BACKEND_UATRACE # default OFF
LOGIT_BACKEND_WINDOWS_DEBUGGER # default OFF- Option:
-DLOGIT_BACKEND_STDOUTLOG=ON - Extra dependencies: none
- Option:
-DLOGIT_BACKEND_BOOSTLOG=ON - Requires env var
BOOST_HOMEpointing to a Boost install prefix that contains Boost CMake config files (BoostConfig.cmake) andBoost::log.
- Option:
-DLOGIT_BACKEND_UATRACE=ON - Requires env var
UNIFIED_AUTOMATION_HOMEpointing to a prefix containingUASDKCPPConfig.cmakeand targetUASDKCPP::uabasecpp.
- Option:
-DLOGIT_BACKEND_WINDOWS_DEBUGGER=ON - No external dependency
- Effective only on Windows (
_WIN32), where logs are sent toOutputDebugString.
Include:
#include "LogIt.h"Initialize once:
Log::initializeLogging(Log::INF);Log::initializeLogging(...) returns false if initialization was already done before.
Before initialization, LOG(...) calls are ignored.
Log without a component:
LOG(Log::INF) << "service started";Register and use a component:
const Log::LogComponentHandle ioComp = Log::registerLoggingComponent("IO", Log::WRN);
LOG(Log::ERR, ioComp) << "connection lost";
LOG(Log::DBG, "IO") << "retrying";Adjust verbosity at runtime:
Log::setNonComponentLogLevel(Log::DBG);
Log::setComponentLogLevel(ioComp, Log::TRC);Log levels:
TRC, DBG, INF, WRN, ERRMessage format generated by LogRecord:
YYYY-MM-DD HH:MM:SS.UUUUUU [File.cpp:123, INF] message
YYYY-MM-DD HH:MM:SS.UUUUUU [File.cpp:123, DBG, IO] message
- Components are registered once and kept for process lifetime.
- Maximum registered components is currently
512(Log::g_sMaxComponentIdCount). - Logging with a component handle is faster than logging with a component name (name lookup is required).
Current CI configuration (ci/gitlab/normal.yml) builds matrix profiles on:
- Quasar Windows 2025 container
- Quasar Linux Alma10 container
- Base Linux Alma 10 container
Profiles include combinations of:
STDOUTSTDOUT + BOOSTSTDOUT + UATRACESTDOUT + WINDOWS_DEBUGGER(Windows job)ALL
- Public headers:
include/ - Core implementation:
src/ - CMake modules/options:
cmake/ - GitLab CI config:
ci/gitlab/normal.yml
See LICENSE.TXT (GNU LGPL v3 text, including referenced GPL v3 terms).