Commit 93763588 authored by Ingo Heimbach's avatar Ingo Heimbach

Added a readme file

parent d487480d
Pipeline #1031 skipped
Simple C++ Logger
#################
Overview
========
This project provides a simple C++ logger class and API. It supports different logging levels and colorized logging
output. Logging messages that do not conform to the desired display logging level are filtered in the preprocessor
stage and do not affect the program runtime. Therefore, you can add as many logging messages as you want without
affecting cpu or memory usage of the production version of your software.
Currently, Linux and macOS are supported. It is not tested on Windows yet.
Usage
=====
Just add ``logger.cpp`` and ``logger.hpp`` to your project files; they have no dependencies to other libraries. Then
you can use the global default logger by calling:
.. code-block:: cpp
logger(DEBUG, << "my logging output of variable x" << x << std::endl);
You can output every variable that can be shifted ``<<`` into a ``std::ostream`` object like ``std::cout`` or
``std::cerr``.
Currently, 5 levels of logging output are supported. The levels can be enabled or disabled step-by-step to increase or
decrease the verbosity of the program:
- ``DEBUG``
- ``INFO``
- ``WARNING``
- ``ERROR``
- ``CRITICAL``
Each logging level is displayed in a different color.
The displayed logging levels can be controlled by a ``DEFAULT_LOG_LEVEL`` macro. If it is not set it defaults to
``DEBUG`` in a debug environment (``NDEBUG`` macro not set). If ``NDEBUG`` is set, the default logging level is
``WARNING``. The logger can be disabled completely by setting an ``NLOG`` macro. The chosen log level automatically
includes log levels that are less verbose. For example, if ``WARNING`` is set, ``ERROR`` and ``CRITICAL`` logging
messages are also printed to screen.
Example
=======
For a small demonstration, you can compile and execute the test program included in the ``src/`` directory by
entering:
.. code-block:: bash
make
./test
You should get the following output:
.. image:: http://iffwww/pub/media/simple_cpp_logger.gif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment