Skip to content

quasar-team/LogIt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogIt

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.

Requirements

  • CMake >= 3.30
  • C++17 compiler

Optional dependencies are only required for optional backends (see below).

Build

Default build (stdout backend, object library):

cmake -S . -B build
cmake --build build --config Release

LOGIT_BUILD_SHARED_LIB controls the target type:

  • OFF (default): builds LogIt as an OBJECT library
  • ON: builds LogIt as a SHARED library

Example shared-library build:

cmake -S . -B build -DLOGIT_BUILD_SHARED_LIB=ON
cmake --build build --config Release

Integration Notes

  • This project currently has no install() or package export rules.
  • With LOGIT_BUILD_SHARED_LIB=OFF, LogIt is an object-library target intended for use inside the same CMake build.
  • With LOGIT_BUILD_SHARED_LIB=ON, LogIt is produced as a shared library.

Backend Options

Available CMake options:

LOGIT_BACKEND_STDOUTLOG          # default ON
LOGIT_BACKEND_BOOSTLOG           # default OFF
LOGIT_BACKEND_UATRACE            # default OFF
LOGIT_BACKEND_WINDOWS_DEBUGGER   # default OFF

1. Stdout backend

  • Option: -DLOGIT_BACKEND_STDOUTLOG=ON
  • Extra dependencies: none

2. Boost rotating-file backend

  • Option: -DLOGIT_BACKEND_BOOSTLOG=ON
  • Requires env var BOOST_HOME pointing to a Boost install prefix that contains Boost CMake config files (BoostConfig.cmake) and Boost::log.

3. Unified Automation trace backend

  • Option: -DLOGIT_BACKEND_UATRACE=ON
  • Requires env var UNIFIED_AUTOMATION_HOME pointing to a prefix containing UASDKCPPConfig.cmake and target UASDKCPP::uabasecpp.

4. Windows debugger backend

  • Option: -DLOGIT_BACKEND_WINDOWS_DEBUGGER=ON
  • No external dependency
  • Effective only on Windows (_WIN32), where logs are sent to OutputDebugString.

API Quick Start

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, ERR

Message 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

Component Notes

  • 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).

CI Coverage

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:

  • STDOUT
  • STDOUT + BOOST
  • STDOUT + UATRACE
  • STDOUT + WINDOWS_DEBUGGER (Windows job)
  • ALL

Repository Layout

  • Public headers: include/
  • Core implementation: src/
  • CMake modules/options: cmake/
  • GitLab CI config: ci/gitlab/normal.yml

License

See LICENSE.TXT (GNU LGPL v3 text, including referenced GPL v3 terms).

About

Stand alone LogIt

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors