https://github.com/bringauto/ba-logger
BringAuto logger library - simple logging abstraction
https://github.com/bringauto/ba-logger
Last synced: 4 months ago
JSON representation
BringAuto logger library - simple logging abstraction
- Host: GitHub
- URL: https://github.com/bringauto/ba-logger
- Owner: bringauto
- License: lgpl-3.0
- Created: 2022-03-30T12:17:56.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-04-08T09:53:08.000Z (about 1 year ago)
- Last Synced: 2025-04-08T10:36:00.690Z (about 1 year ago)
- Language: C++
- Homepage:
- Size: 397 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BringAuto Logger Library
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.
## Requirements
Before building the library, ensure the following dependencies are installed on your host system:
- **CMake** [>= 3.20]
- **C++20**
- **[cmlib](https://github.com/cmakelib/cmakelib)**
- **[spdlog](https://github.com/gabime/spdlog)**
- **[Google Test](https://github.com/google/googletest/blob/main/googletest/README.md)** (for running tests)
## Build Instructions
To build the library, follow these steps:
```bash
mkdir -p _build && cd _build
cmake .. -DCMAKE_INSTALL_PREFIX= -DLIB_TYPE=SPDLOG -DCMAKE_BUILD_TYPE=Release [-DCMLIB_DIR=]
make -j 8
```
Other configuration options
- `BRINGAUTO_SYSTEM_DEP=[ON|OFF]` - set the variable to `ON` if the system installed dependencies should be used instead of precompiled ones
### Environment Variable
If CMLIB is installed and the `CMLIB_DIR` environment variable is set, you can omit the `-DCMLIB_DIR=` option.
### Implementations
Specify the logging implementation type with the `-DLIB_TYPE=` option. Supported types are:
- **DUMMY**: For testing purposes; outputs log messages to the console.
- **SPDLOG**: Utilizes the [spdlog](https://github.com/gabime/spdlog) logging library.
### Example Application
To build the example application, enable the `BRINGAUTO_SAMPLES` option in CMake:
```bash
cmake .. -DBRINGAUTO_SAMPLES=ON
```
The executable for the example application will be located in the `./_build/example/` directory.
### Running Tests
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:
```bash
ctest .
```
from within the `_build` directory after configuring with `-DBRINGAUTO_TESTS=ON`.
## Usage
To integrate the library into your project:
1. **Generate a Package**: Use the `cpack` command to create a package.
2. **Install the Package**: Install the package on your system.
3. **Include in CMake**:
```cmake
FIND_PACKAGE(libbringauto_logger)
TARGET_LINK_LIBRARIES( bringauto_logger::bringauto_logger)
```
4. **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.
## Installation
To install the library, enable the `BRINGAUTO_INSTALL` option in CMake:
```bash
cmake .. -DBRINGAUTO_INSTALL=ON
```
To create a package, use the `BRINGAUTO_PACKAGE` option and rename the package to follow our naming convention: `__-.`. For example: `libbringauto_logger_1.5.01_amd64-ubuntu2004.zip`.