liberate is a small platform liberation library for the Interpeer Project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jens Finkhaeuser 787506c789 Update '' 16 hours ago
changelog.d Changelog entry for copyright transfer 1 month ago
docs Try adding logo 16 hours ago
examples For #9, this change ensures that internal projects have a dependency 2 months ago
include Add secure memset/memzero as API functions 5 days ago
lib Add secure memset/memzero as API functions 5 days ago
scripts Update appveyor matrix 2 months ago
subprojects Bump dependency 2 months ago
test Add secure memset/memzero as API functions 5 days ago
.appveyor.yml Appveyor seems to work on migrated repo 2 months ago
.appveyor_account.yml Add missing appveyor account info 2 months ago
.gitignore Update ignores 2 months ago
.oclint Add oclint config 2 years ago
.semgrepignore Update copyright notice; there was an error 4 weeks ago
.woodpecker.yml CI images should be latest 1 month ago Add license info 2 years ago Add license info 2 years ago Update copyright notice; there was an error 4 weeks ago
DCO.txt Add license info 2 years ago
LICENSE Remove superfluous letter 2 weeks ago
Pipfile Update copyright to Interpeer gUG, instructions 1 month ago
Pipfile.lock Update copyright to Interpeer gUG, instructions 1 month ago Update '' 16 hours ago Add secure memset/memzero as API functions 5 days ago
flake.lock Update Nixpkgs 9 months ago
flake.nix flake.nix: Use same gtest as specified in subprojects/gtest.wrap 9 months ago Fix detection for SecureZeroMemory (it's a macro) 5 days ago
meson_options.txt Make logging backend a combo option 1 year ago
towncrier.toml Probable boilerplate for a changelog maintenance tool 5 months ago


status-badge Build status

liberate is a small platform liberation library for the Interpeer Project.

The scope of the project is bound to the needs of the overall proejct. It may change over time. For now, the focus is on the subset of platform abstractions that are shared amongst several other projects:


  1. liberate/checksum/ contains a header-only implementation of CRC32 with various polynomials.
  2. liberate/concurrency contains some useful classes for concurrent algorithms.
  3. liberate/cpp/ contains headers that make some C++ language features a little more accessible.
  4. liberate/fs/ contains simple operating system abstractions of file system operations.
  5. liberate/net/ contains classes for socket and network addresses, and a simple URL parser for socket-URLs.
  6. liberate/string/ contains some string utilities.
  7. liberate/serialization/ contains functions for serializing and deserializing value types.
  8. liberate/sys/ contains miscellaneous operating system abstractions.
  9. liberate/types{.h} contains standard type headers, as well as type definitions such as a variable length integer type.
  10. liberate/visibility.h contains library symbol visibility macros that can be re-used in other libraries.
  11. liberate/logging.h contains logging macros.


Liberate itself does not provide genuine logging facilities. It does, however, provide macros which delegate to one of several logging backends, or to a simple stderr-based logging mechanism. The purpose of these macros is to provide the same logging interface for liberate and it's dependent project, but leave the project user in control of where log data is sent.

You choose the logging backend from meson_options.txt, or by passing the -DLIBERATE_LOG_BACKEND compiler flag. Note that depending on how you use the macros, either option may be more appropriate for you. If all your projects are built with meson, in the top-level project do:

$ cd <build-dir>
$ meson <source-dir> -Dliberate:log_backend=plog

Everything should build with the selected backend. Note that depending on the backend you choose, you may need to promote the backend's subproject, but meson will provide instructions for how to do that.

Possible backends are:

  1. loguru
  2. plog
  3. spdlog
  4. Builtin stderr log.

Log Levels

In order of descending verbosity:

Liberate loguru plog spdlog

Log Macros

  • LIBLOG(LEVEL, message) log message at the given log level.
  • LIBLOG_<LEVEL_WITHOUT_PREFIX>(message) shorthand for the above.
  • Short versions of the above: LLOG_<FIRST_LEVEL_LETTER>(message).
  • LIBLOG_ERR(code, message) logs the given message. The code is considered a platform error code, as returned by e.g. errno or GetLastError().
  • LIBLOG_ERRNO(message) same as above, but uses errno/WSAGetLastError() internally to retrieve the platform error code.
  • LIBLOG_EXC(exception, message) logs the message, followed by the exception's .what().

All of the shorthand macros above for logging error information log at LIBLOG_ERROR level. The below, therefore, are all equivalent:

char buf[200] = {};
snprintf("%s // %s", msg, strerror(errno));

LIBLOG_ERR(errno, msg);

auto exc = hypothetical_make_exception(errno);
LIBLOG_EXC(exc, msg);

Builtin logger

The builtin stderr log is very simple: it prefixes each log entry with the file and line number, and the severity. Additionally, it only produces output if the -DDEBUG flag is set and the -DNDEBUG flag is unset, so that you can produce entirely log-free release binaries.

Other Backends

Liberate does not initialize other logging backends. It includes the selected backend headers, but does nothing else. You can use the logging header to write log messages, but where they end up is up to your project's initialization code.

  • loguru:
    • In the examples, FATAL error messages are redirected to ERROR, to demonstrate all LIBLOG* macros appropriately.
    • The library cannot be used on Android or Win32.
  • plog:
    • The library cannot be used on Win32.