BringAuto Logger Library provides a robust and stable API for logging.
The library serves as a consistent API to provide access to different logging libraries, formats, and technologies.
This library consists of header files (.hpp) and multiple implementations. To use the library compile it with your desired implementation, install it (or create a package) and follow the instructions in the Usage section.
Before building the library, ensure the following dependencies are installed on your host system:
- CMake [>= 3.20]
- C++20
- spdlog
- Google Test (for running tests)
To build the library, follow these steps:
mkdir -p build && cd build
cmake ..
make -j 8Other configuration options
LIB_TYPE=<TYPE>- specify the logging implementation (see Implementations below); defaults toSPDLOGCMAKE_BUILD_TYPE=<TYPE>- build type (e.g.Release,Debug)CMAKE_INSTALL_PREFIX=<path>- installation prefix
Dependency resolution strategy (BA_PACKAGE_SOURCE, default AUTO):
AUTO- tries system → prebuilt → FetchContent in order, stops at first successSYSTEM_PACKAGES- system-installed spdlog only; error if not foundPREBUILT_PACKAGES- prebuilt package from Gitea only; error if not foundFETCH_CONTENT- clone and build from source via FetchContent
Specify the logging implementation type with the -DLIB_TYPE=<TYPE> option. Supported types are:
- DUMMY: For testing purposes; outputs log messages to the console.
- SPDLOG: Utilizes the spdlog logging library.
To build the example application, enable the BRINGAUTO_SAMPLES option in CMake:
cmake .. -DBRINGAUTO_SAMPLES=ONThe executable for the example application will be located in the ./_build/example/ directory.
To build and run tests, use the following options:
- Build Tests: Use the flag
-DBRINGAUTO_TESTS=ON. Test executables will be located in the./_build/tests/directory.
To execute the tests, run:
ctest .from within the _build directory after configuring with -DBRINGAUTO_TESTS=ON.
To integrate the library into your project:
-
Generate a Package: Use the
cpackcommand to create a package. -
Install the Package: Install the package on your system.
-
Include in CMake:
FIND_PACKAGE(libbringauto_logger) TARGET_LINK_LIBRARIES(<target> bringauto_logger::bringauto_logger)
-
Initialize Logger:
- Call
Logger::addSink()with the desired sink and parameters. - Call
Logger::init()to finalize the setup. - After initialization, you can use the logging functions. Refer to the example application for detailed usage.
- Call
To install the library, enable the BRINGAUTO_INSTALL option in CMake:
cmake .. -DBRINGAUTO_INSTALL=ONTo create a package, use the BRINGAUTO_PACKAGE option and rename the package to follow our naming convention: <packagename>_<version>_<architecture>-<distro>.<extension>. For example: libbringauto_logger_1.5.01_amd64-ubuntu2004.zip.