This is a simple logging library which can be used to send log messages to a Graylog server. This is done by creating messages in the GELF format and sending them to a Graylog server via TCP. For testing purposes a Vagrant machine running Graylog can be used. A simple Vagrantfile for creating this set-up can be found here. The argument for creating yet another logging library instead of writing a plugin/sink/handler for an already existing one is that a relatively light weight solution was desired. The library has functionality for writing log messages to console and file as well. By default the library will only write log messages to console.
The repository is split into four parts:
- The logging library.
- Unit tests of the logging library which are completely self contained (i.e. does not require a Graylog server).
- A simple console application which uses the logging library.
- Some benchmarking code which is used for profiling and optimising the code as well as test for performance regression.
A sister project to this library is the Python logging handler GraylogHandler.
- Further documentation can be found here.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
The logging library has the following (requried) external dependencies:
- moodycamel::ConcurrentQueue For message passing to and within the logging library.
- JSONForModernCPP For generating graylog GELF messages.
- ASIO For networking.
This library can also make use of the following (optional) dependencies:
- libfmt For doing fast (multi-threaded) string formatting.
- GTest For unit testing.
- google-benchmark For benchmarking.
You will also need CMake (version ≥ 3.9) to build the project. The project makes use of library and language features provided by C++14. It might be possible to link to the library using compilers that only supports C++11 though this has not been tested.
Due to the use of ASIO, the library should compile on most *nix systems and Windows 10 with no issues though only limited testing has been done.
There are two methods for building this library. They are described below.
When using conan to provide the dependencies, all the optional and required dependencies are provided automatically. To checkout and build the library, run the following commands:
git clone https://github.com/ess-dmsc/graylog-logger.git
cd graylog-logger
mkdir build
cd build
conan install .. --build=outdated
cmake ..
make install
If you are creating a conan package of this library you should disable CMake from running Conan by providing the following argument to CMake: -DCONAN=DISABLE
. Furthermore, you must also use the cmake_find_package
generator for CMake to be able to find the dependencies.
If using conan is not an option, it is possible to build the library using system installed dependencies. This requires a bit more work though and might not be as reliable.
Run the following commands:
git clone https://github.com/ess-dmsc/graylog-logger.git
cd graylog-logger
mkdir build
cd build
cmake .. -DCONAN=DISABLE -DCMAKE_PREFIX_PATH=/path/to/dir/containing/the/concurrentqueue/directory/
make install
The code has some documentation. To generate it, run doxygen in the root of the repository i.e.:
cd graylog-logger
doxygen
If compiled, the unit tests are run by running the unit_tests
application in the unit_tests
directory of the build
directory.
Examples illustrating how the library can be used can be found in the examples.md file.
Get in contact by creating an issue. I will be happy to assist you making the changes that you want.
We use SemVer for versioning. For the versions available, see the releases on github.
- Jonas Nilsson - Initial work - SkyToGround
- Afonso Mukai - Provided much assistance in setting up the continous integration system.
- Matthew Jones - Improved the CMake code and suggested improvements to the interface.
See also the list of contributors to this project.
This project is licensed under the BSD-2 License - see the LICENSE.md file for details