liberate is a small platform liberation library for the Interpeer Project. https://interpeer.io
 
 
 
 
 
Go to file
Jens Finkhaeuser 8b54e65d84
ci/woodpecker/push/woodpecker Pipeline was successful Details
Migrate clone changes over from s3kr1t
2023-05-04 09:42:04 +02:00
changelog.d Add missing changelog entry 2023-05-02 17:28:09 +02:00
docs Try adding logo 2022-07-05 18:03:30 +02:00
examples Disable tests, examples in conan build 2022-10-07 10:22:09 +02:00
include Add ULEB128 encoding to the existing SLEB128 2022-12-12 14:00:14 +01:00
lib Add SPDX identifier 2022-07-25 12:18:05 +02:00
scripts Upload command changed 2023-05-02 17:48:08 +02:00
subprojects Bump dependency 2022-05-20 09:07:44 +02:00
test Add ULEB128 encoding to the existing SLEB128 2022-12-12 14:00:14 +01:00
test_package Test package README 2022-10-07 10:21:47 +02:00
.appveyor.yml Appveyor seems to work on migrated repo 2022-04-29 15:24:37 +02:00
.appveyor_account.yml Add missing appveyor account info 2022-04-29 14:26:28 +02:00
.bumpversion.cfg Bump version: 0.1.0 → 0.2.0 2022-10-13 14:10:35 +02:00
.gitignore Ignore conan build files 2022-10-12 12:18:06 +02:00
.oclint Add oclint config 2020-07-09 17:57:26 +02:00
.semgrepignore Update copyright notice; there was an error 2022-06-09 14:49:00 +02:00
.woodpecker.yml Migrate clone changes over from s3kr1t 2023-05-04 09:42:04 +02:00
AUTHORS Update codemeta.json from repocheck 2022-07-25 12:17:22 +02:00
CHANGES Add CHANGES from fragments 2022-10-13 14:09:16 +02:00
CODE_OF_CONDUCT.md Add license info 2020-07-09 14:01:45 +02:00
CONTRIBUTING.md Update copyright notice; there was an error 2022-06-09 14:49:00 +02:00
DCO.txt Add license info 2020-07-09 14:01:45 +02:00
LICENSE Remove superfluous letter 2022-06-24 10:29:31 +02:00
Pipfile Bump conan to 2.x, other dependencies 2023-05-02 15:52:37 +02:00
Pipfile.lock Bump conan to 2.x, other dependencies 2023-05-02 15:52:37 +02:00
README.md Add vessel to libraries using liberate 2022-10-13 13:50:55 +02:00
build-config.h.in Add secure memset/memzero as API functions 2022-07-01 12:49:33 +02:00
codemeta.json Update codemeta.json from repocheck 2022-07-25 12:17:22 +02:00
conandata.yml First stab; the conanfile should work in a template 2022-10-04 11:08:02 +02:00
conanfile.py Use really latest image 2023-05-02 16:46:45 +02:00
meson.build Bump version: 0.1.0 → 0.2.0 2022-10-13 14:10:35 +02:00
meson_options.txt Disable tests, examples in conan build 2022-10-07 10:22:09 +02:00
towncrier.toml Probable boilerplate for a changelog maintenance tool 2022-02-10 18:47:33 +01:00

README.md

liberate

status-badge Build status Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

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:

Contents

  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.

Logging

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
LIBLOG_LEVEL_TRACE 9 verbose TRACE
LIBLOG_LEVEL_DEBUG 1 debug DEBUG
LIBLOG_LEVEL_INFO INFO info INFO
LIBLOG_LEVEL_WARN WARN warning WARN
LIBLOG_LEVEL_ERROR ERROR error ERROR
LIBLOG_LEVEL_FATAL FATAL fatal CRITICAL

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(LIBLOG_LEVEL_ERROR, buf);
LIBLOG_ERROR(buf);
LLOG_E(buf);
LIBLOG_ERR(errno, msg);
LIBLOG_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.