| 1 |
/* |
| 2 |
* Copyright (C) 2014 Karel Zak <[email protected]> |
| 3 |
* |
| 4 |
* This file may be redistributed under the terms of the |
| 5 |
* GNU Lesser General Public License. |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* SECTION: init |
| 10 |
* @title: Library initialization |
| 11 |
* @short_description: initialize debugging |
| 12 |
* |
| 13 |
* The library debug stuff. |
| 14 |
*/ |
| 15 |
|
| 16 |
#include <stdarg.h> |
| 17 |
|
| 18 |
#include "smartcolsP.h" |
| 19 |
|
| 20 |
UL_DEBUG_DEFINE_MASK(libsmartcols); |
| 21 |
UL_DEBUG_DEFINE_MASKNAMES(libsmartcols) = |
| 22 |
{ |
| 23 |
{ "all", SCOLS_DEBUG_ALL, "info about all subsystems" }, |
| 24 |
{ "buff", SCOLS_DEBUG_BUFF, "output buffer utils" }, |
| 25 |
{ "cell", SCOLS_DEBUG_CELL, "table cell utils" }, |
| 26 |
{ "col", SCOLS_DEBUG_COL, "cols utils" }, |
| 27 |
{ "help", SCOLS_DEBUG_HELP, "this help" }, |
| 28 |
{ "group", SCOLS_DEBUG_GROUP, "lines grouping utils" }, |
| 29 |
{ "line", SCOLS_DEBUG_LINE, "table line utils" }, |
| 30 |
{ "tab", SCOLS_DEBUG_TAB, "table utils" }, |
| 31 |
{ "filter", SCOLS_DEBUG_FLTR, "lines filter" }, |
| 32 |
{ "fparam", SCOLS_DEBUG_FPARAM, "filter params" }, |
| 33 |
{ NULL, 0, NULL } |
| 34 |
}; |
| 35 |
|
| 36 |
/** |
| 37 |
* scols_init_debug: |
| 38 |
* @mask: debug mask (0xffff to enable full debugging) |
| 39 |
* |
| 40 |
* If the @mask is not specified, then this function reads |
| 41 |
* the LIBSMARTCOLS_DEBUG environment variable to get the mask. |
| 42 |
* |
| 43 |
* Already initialized debugging stuff cannot be changed. Calling |
| 44 |
* this function twice has no effect. |
| 45 |
*/ |
| 46 |
void scols_init_debug(int mask) |
| 47 |
{ |
| 48 |
if (libsmartcols_debug_mask) |
| 49 |
return; |
| 50 |
|
| 51 |
__UL_INIT_DEBUG_FROM_ENV(libsmartcols, SCOLS_DEBUG_, mask, LIBSMARTCOLS_DEBUG); |
| 52 |
|
| 53 |
if (libsmartcols_debug_mask != SCOLS_DEBUG_INIT |
| 54 |
&& libsmartcols_debug_mask != (SCOLS_DEBUG_HELP|SCOLS_DEBUG_INIT)) { |
| 55 |
const char *ver = NULL; |
| 56 |
|
| 57 |
scols_get_library_version(&ver); |
| 58 |
|
| 59 |
DBG(INIT, ul_debug("library debug mask: 0x%04x", libsmartcols_debug_mask)); |
| 60 |
DBG(INIT, ul_debug("library version: %s", ver)); |
| 61 |
} |
| 62 |
ON_DBG(HELP, ul_debug_print_masks("LIBSMARTCOLS_DEBUG", |
| 63 |
UL_DEBUG_MASKNAMES(libsmartcols))); |
| 64 |
} |