logging-internal.h: add BT_LOG_LEVEL_EXTERN_SYMBOL(), BT_LOG_INIT_LOG_LEVEL()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 31 May 2017 16:48:52 +0000 (12:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 20:58:13 +0000 (16:58 -0400)
commit5d2d01c46285cd45104c6ed91dd46fb47fc9f224
tree6b2abb1b96edfb807bacc3aeab52edec6de91f02
parentdfef83678096e9fd1ebe2a48b5e9ace3c9df9b93
logging-internal.h: add BT_LOG_LEVEL_EXTERN_SYMBOL(), BT_LOG_INIT_LOG_LEVEL()

BT_LOG_INIT_LOG_LEVEL() defines a hidden log level symbol and a static
constructor which initializes this symbol according to the value of
a given environment variable. This macro should be used in a module-wise
dedicated logging source file, `logging.c`, as such:

    #define BT_LOG_OUTPUT_LEVEL some_log_level_symbol
    #include <babeltrace/logging-internal.h>

    BT_LOG_INIT_LOG_LEVEL(some_log_level_symbol, "BABELTRACE_SOME_LOG_LEVEL");

BT_LOG_LEVEL_EXTERN_SYMBOL() declares this symbol as `extern`. It
should be used in a module-wise dedicated logging header, `logging.h`,
as such:

    #define BT_LOG_OUTPUT_LEVEL some_log_level_symbol
    #include <babeltrace/logging-internal.h>

    BT_LOG_LEVEL_EXTERN_SYMBOL(some_log_level_symbol);

Any module source file which contains log statements should use the
following lines **before any #include line**:

    #define BT_LOG_TAG "THE-MODULE-TAG"
    #include "logging.h"

If there are subdirectories within a module, it is possible that you
need to include "../logging.h" or "../../logging.h", for example. The
rule of thumb is that no module file, except `logging.c`, should include
<babeltrace/logging-internal.h> directly.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/logging-internal.h
This page took 0.024648 seconds and 4 git commands to generate.