A simple and maybe thread-safe logging library I use across a variety of my personal projects and some projects at work
- Get a C++20 compiler and a standard library that supports
std::format(or fmtlib, see below); - Copy the contents of
uulogdirectory somewhere around your project and make sure your source code can includeuulog.hh; - Include
uulog.hhand register some pre-defined sinks or define and use your own; - Issue log messages:
LOG_DEBUG,LOG_INFO,LOG_WARNING,LOG_ERRORandLOG_CRITICAL; - If you want to use fmtlib ( 🤢 ), define
UULOG_USE_FMTLIBbefore including the header;
- Clone the repository into your project and remove the sub-repo's
.gitfolder; - Add an
add_subdirectorycall; - Optionally clean all the unnecessary stuff from both the source tree and CMakeLists.txt;
- Add a dependency on
uuloglibrary somewhere; - Include
uulog.hhand register some pre-defined sinks or define and use your own; - Issue log messages:
LOG_DEBUG,LOG_INFO,LOG_WARNING,LOG_ERRORandLOG_CRITICAL; - If you want to use fmtlib ( 🤢 ) this way, tough luck. I can't be bothered with figuring out how to wrench my way into using it via
find_package, besides managing dependencies by yourself is the way;
Under construction
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
I do not debug with std::format, I do not use print debugging in high call-rate functions, I do not profile a logger. If something runs slow because of a bunch of LOG_INFO statements, I comment them out

- Compile uulog as a shared library via
BUILD_SHARED_LIBS - Define
UULOG_DLLfor dependent projects
The for-each loop for every uulog::Sink registered into the logger is wrapped with an internal mutex (the exact same one used to register and de-register sinks) so the sink is to assume it is safe to access a resource
Whenever NDEBUG is defined, the compiled library doesn't provide uulog::detail::debug function nor does LOG_DEBUG do anything apart from being pre-processed as ((void)0)

