This project started as a clone of loguru. Since 2.0.0, this is a very stripped-down version of loguru that works well in the context of a Rack Extension. See here for more details.
- Include
re-logging.cmake
in the project - Add
${re-logging_INCLUDE_DIRS}
totarget_include_directories()
- Because of the rack extension environment/limitations,
logging.cpp
can only be compiled in native builds
The project is then included like this:
#include <logging.h>
It is strongly recommended to use re-cmake for building a rack extension.
Check RE Quickstart for a quick and convenient way to generate a blank rack extension that use re-logging
.
This project offers a set of macros:
Macro | Description |
---|---|
DLOG_F(verbosity, ...) |
The main macro used for logging (note that the name was kept from loguru).
Using verbosity FATAL will cause the message to be displayed and the program aborted. |
DCHECK_F(test, ...) | This macro checks that the expression resolves to true and aborts if not |
DCHECK_NOTNULL_F(x, ...) | This macro checks that the expression is not null and aborts if not |
DCHECK_EQ_F(a, b, ...) | This macro checks that a == b and aborts if not |
DCHECK_NE_F(a, b, ...) | This macro checks that a != b and aborts if not |
DCHECK_LT_F(a, b, ...) | This macro checks that a < b and aborts if not |
DCHECK_LE_F(a, b, ...) | This macro checks that a <= b and aborts if not |
DCHECK_GT_F(a, b, ...) | This macro checks that a > b and aborts if not |
DCHECK_GE_F(a, b, ...) | This macro checks that a >= b and aborts if not |
ABORT_F(...) |
Logs the message and aborts. Note that if RE_LOGGING_INIT_FOR_TEST is called, then it will throw a catchable exception instead of aborting which is useful for testing purposes |
RE_LOGGING_INIT_FOR_RE(re_name) | This macro can be called when the device is created to make the output nicer |
RE_LOGGING_INIT_FOR_TEST(prefix) | This macro can be used from tests to replace "abort" with exception (which can be checked) |
RE_LOGGING_SET_VERBOSITY(verbosity) |
This macro changes the verbosity level. Possible values are:
|
JBOX_LOGVALUES(iMessage, ...) |
Allows writing simpler code
// using JBOX_TRACEVALUES TJBox_Value instanceIDValue = JBox_MakeNumber(JBox_GetNumber(iParams[0])); TJBox_Value array[1]; array[0] = instanceIDValue; JBOX_TRACEVALUES("instance ID = ^0", array, 1); |
This project offers a set of C defines:
Define | Default | Description |
---|---|---|
RE_LOGGING_DEFAULT_VERBOSITY |
INFO |
The default level of verbosity. Can be changed at runtime with the RE_LOGGING_SET_VERBOSITY macro |
RE_LOGGING_STRIP_FILE_PATH |
1 |
Whether to display only the filename (1) by stripping the file path or the full path (0) |
- Simplified prefix logic
- Fixed prefix override
- Removed most of the loguru implementation in favor of a lighter implementation (#1)
- Only the major loguru APIs were kept (
DLOG_F
,ABORT_F
,DCHECK_F
andDCHECK_*_F
variants) - Added
RE_LOGGING_SET_VERBOSITY
macro to change the logging verbosity at runtime - Added
RE_LOGGING_DEFAULT_VERBOSITY
C define to change the default logging verbosity at compilation time (default toINFO
) - Added
RE_LOGGING_STRIP_FILE_PATH
C define to change if the filename or the full path is displayed (default to filename) - Replaced
loguru::init_for_re
(now deprecated) with the macroRE_LOGGING_INIT_FOR_RE
- Replaced
loguru::init_for_test
(now deprecated) with the macroRE_LOGGING_INIT_FOR_TEST
- Does not fail anymore when included via
FetchContent_MakeAvailable
- Fix for Windows 10 build
- First release.
-
This project is released under the terms of the Apache 2.0 license
-
This project is a very stripped-down version of loguru which is distributed with the following license:
This software is in the public domain. Where that dedication is not recognized, you are granted a perpetual, irrevocable license to copy, modify and distribute it as you see fit
-
This project uses the Rack extension SDK released under the Rack Extension License agreement