1 HEAD~ Log Flags; logflags; define hierarchies for logging output
3 Flags are used to inform NoBug about subsystems/modules or even finer
4 grained sections of the code. These are referred to as 'channels' in other
7 A flag should be declared in a headerfile using the following mechanism:
9 INDEX DECLARE_FLAG; DECLARE_FLAG; declaring a flag
10 NOBUG_DECLARE_FLAG(flagname)
12 It is advisable to do so in one of your header files.
14 Furthermore, the flag must be defined in some implementation file by using one
15 of the following schemes:
17 INDEX DEFINE_FLAG; DEFINE_FLAG; defining a flag
18 NOBUG_DEFINE_FLAG(flagname)
22 INDEX DEFINE_FLAG_LIMIT; DEFINE_FLAG_LIMIT; defining a flag w/ log limit
23 NOBUG_DEFINE_FLAG_LIMIT(flagname, limit)
25 Moreover, macros are available that accept a 'parent' flag as a parameter, which is then
26 used to initialize the defaults from another flag:
28 INDEX DEFINE_FLAG_PARENT; DEFINE_FLAG_PARENT; defining a flag hierarchy
29 NOBUG_DEFINE_FLAG_PARENT(flagname, parent)
33 INDEX DEFINE_FLAG_PARENT_LIMIT; DEFINE_FLAG_PARENT_LIMIT; defining a flag hierarchy, w/ log limit
34 NOBUG_DEFINE_FLAG_PARENT_LIMIT(flagname, parent, limit)
36 This can be used to create hierachies of flags
39 PARA C++ support, C++ logflags; Cplusplus_logflags; C++ support for log flags
41 Additional macros are available for applications written in C++:
43 NOBUG_CPP_DEFINE_FLAG(name)
44 NOBUG_CPP_DEFINE_FLAG_PARENT(name, parent)
45 NOBUG_CPP_DEFINE_FLAG_LIMIT(name, default)
46 NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT(name, parent, default)
48 These macros statically initialize the flags when they are defined, there is no
49 need to call `NOBUG_INIT_FLAG()` (see below).
52 .Force declarations only
54 When the the following preprocessor constant is defined to be `1`:
56 INDEX DECLARE_ONLY; DECLARE_ONLY; force flag declarations only
59 then *all* definitions here (`NOBUG_DEFINE_*`)
60 become declarations only. When this is defined to be `0` (which is the
61 default) then all definitions behave as described.
62 This can be used to construct a headerfile which only contains
63 definitions, but, by default, yield only declarations. This provides one
64 convenient single point to maintain flag configurations.
66 .Maintaining flags in a single header 'flags.h'
72 if not included from flags.c then declare the flags,
76 #define NOBUG_DECLARE_ONLY 1
79 /* use only DEFINE_FLAG here */
80 NOBUG_DEFINE_FLAG(example);
83 Reset it to 0 to cause no trouble
86 #undef NOBUG_DECLARE_ONLY
87 #define NOBUG_DECLARE_ONLY 0
100 .Logging Flag Initialization
104 NOBUG_INIT_FLAG(flagname)
108 NOBUG_INIT_FLAG_LIMIT(flagname, default)
110 once at the start of your program for each flag.
112 For flags defined with `NOBUG_DEFINE_FLAG(flagname)` the defaults are initialized
113 as in the xref:logdefaults[table above], while
114 `NOBUG_DEFINE_FLAG_LIMIT(flagname, level)` is used to initialize the
115 default target (depending on build level) to `level`.