blob: 61acb0a4f57fbfd88d4db73d0fed81e94274ec99 [file] [log] [blame]
bigbiff7b4c7a62015-01-01 19:44:14 -05001
2#include "fdiskP.h"
3
4
5/**
6 * SECTION: init
7 * @title: Library initialization
8 * @short_description: initialize debug stuff
9 *
10 */
11
12UL_DEBUG_DEFINE_MASK(libfdisk);
13UL_DEBUG_DEFINE_MASKNAMES(libfdisk) =
14{
15 { "all", LIBFDISK_DEBUG_ALL, "info about all subsystems" },
16 { "ask", LIBFDISK_DEBUG_ASK, "fdisk dialogs" },
17 { "help", LIBFDISK_DEBUG_HELP, "this help" },
18 { "cxt", LIBFDISK_DEBUG_CXT, "library context (handler)" },
19 { "label", LIBFDISK_DEBUG_LABEL, "disk label utils" },
20 { "part", LIBFDISK_DEBUG_PART, "partition utils" },
21 { "parttype", LIBFDISK_DEBUG_PARTTYPE,"partition type utils" },
22 { "script", LIBFDISK_DEBUG_SCRIPT, "sfdisk-like scripts" },
23 { "tab", LIBFDISK_DEBUG_TAB, "table utils"},
24 { NULL, 0 }
25};
26
27/**
28 * fdisk_init_debug:
29 * @mask: debug mask (0xffff to enable full debuging)
30 *
31 * If the @mask is not specified then this function reads
32 * LIBFDISK_DEBUG environment variable to get the mask.
33 *
34 * Already initialized debugging stuff cannot be changed. It does not
35 * have effect to call this function twice.
36 *
37 * It's strongly recommended to use fdisk_init_debug(0) in your code.
38 */
39void fdisk_init_debug(int mask)
40{
41 if (libfdisk_debug_mask)
42 return;
43
44 __UL_INIT_DEBUG(libfdisk, LIBFDISK_DEBUG_, mask, LIBFDISK_DEBUG);
45
46
47 if (libfdisk_debug_mask != LIBFDISK_DEBUG_INIT
48 && libfdisk_debug_mask != (LIBFDISK_DEBUG_HELP|LIBFDISK_DEBUG_INIT)) {
49
50 DBG(INIT, ul_debug("library debug mask: 0x%04x", libfdisk_debug_mask));
51 }
52
53 ON_DBG(HELP, ul_debug_print_masks("LIBFDISK_DEBUG",
54 UL_DEBUG_MASKNAMES(libfdisk)));
55}