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
- cmlib
- spdlog
- Google Test (for running tests)
To build the library, follow these steps:
mkdir -p _build && cd _build
cmake .. -DCMAKE_INSTALL_PREFIX=<path_where_to_install> -DLIB_TYPE=SPDLOG -DCMAKE_BUILD_TYPE=Release [-DCMLIB_DIR=<path_to_cmlib_dir>]
make -j 8
Other configuration options
BRINGAUTO_SYSTEM_DEP=[ON|OFF]
- set the variable toON
if the system installed dependencies should be used instead of precompiled ones
If CMLIB is installed and the CMLIB_DIR
environment variable is set, you can omit the -DCMLIB_DIR=<path_to_cmlib_dir>
option.
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=ON
The 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
cpack
command 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=ON
To 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
.