~registry/lvm2/master

« back to all changes in this revision

Viewing changes to lib/misc/lvm-globals.c

  • Committer: Alasdair G Kergon
  • Date: 2013-01-07 22:25:19 UTC
  • Revision ID: git-v1:7f747a0d739c08eadf319da9c3973f83c97c82af
logging: add debug classes

Add log/debug_classes to lvm.conf to allow debug messages to be
classified and filtered at runtime.

The dm_errno field is only used by log_error(), so I've redefined it
for log_debug() messages to hold the message class.

By default, all existing messages appear, but we can add categories that
generate high volumes of data, such as logging all traffic to/from
lvmetad.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
static int _obtain_device_list_from_udev = DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV;
32
32
static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
33
33
static int _debug_level = 0;
 
34
static int _debug_classes_logged = DEFAULT_LOGGED_DEBUG_CLASSES;
34
35
static int _log_cmd_name = 0;
35
36
static int _ignorelockingfailure = 0;
36
37
static int _security_level = SECURITY_LEVEL;
263
264
        _debug_level = level;
264
265
}
265
266
 
 
267
void init_debug_classes_logged(int classes)
 
268
{
 
269
        _debug_classes_logged = classes;
 
270
}
 
271
 
 
272
int debug_class_is_logged(int class)
 
273
{
 
274
        /* If no class given, log it */
 
275
        if (!class)
 
276
                return 1;
 
277
 
 
278
        return (_debug_classes_logged & class) ? 1 : 0;
 
279
}
 
280
 
266
281
int verbose_level(void)
267
282
{
268
283
        return _verbose_level;