X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fvlog.h;h=0f791af1ae714934b5873c6f43ae5213ce9636cd;hb=003ce655b7116d18c86a74c50391e54990346931;hp=da55405b3ca8c4c6c73155bd3f8ffc1eb11c1cb7;hpb=afc9f54778901086a9565c14e1ce16c3c7aca514;p=sliver-openvswitch.git diff --git a/lib/vlog.h b/lib/vlog.h index da55405b3..0f791af1a 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -35,6 +35,7 @@ #include "sat-math.h" #include "token-bucket.h" #include "util.h" +#include "list.h" #ifdef __cplusplus extern "C" { @@ -78,22 +79,22 @@ enum vlog_facility vlog_get_facility_val(const char *name); /* A log module. */ struct vlog_module { + struct list list; const char *name; /* User-visible name. */ int levels[VLF_N_FACILITIES]; /* Minimum log level for each facility. */ int min_level; /* Minimum log level for any facility. */ bool honor_rate_limits; /* Set false to ignore rate limits. */ }; +/* Global list of all logging modules */ +extern struct list vlog_modules; + /* Creates and initializes a global instance of a module named MODULE. */ -#if USE_LINKER_SECTIONS #define VLOG_DEFINE_MODULE(MODULE) \ VLOG_DEFINE_MODULE__(MODULE) \ - extern struct vlog_module *const vlog_module_ptr_##MODULE; \ - struct vlog_module *const vlog_module_ptr_##MODULE \ - __attribute__((section("vlog_modules"))) = &VLM_##MODULE -#else -#define VLOG_DEFINE_MODULE(MODULE) extern struct vlog_module VLM_##MODULE -#endif + OVS_CONSTRUCTOR(init_##MODULE) { \ + list_insert(&vlog_modules, &VLM_##MODULE.list); \ + } \ const char *vlog_get_module_name(const struct vlog_module *); struct vlog_module *vlog_module_from_name(const char *name); @@ -266,8 +267,9 @@ void vlog_usage(void); extern struct vlog_module VLM_##MODULE; \ struct vlog_module VLM_##MODULE = \ { \ + LIST_INITIALIZER(&VLM_##MODULE.list), \ #MODULE, /* name */ \ - { [ 0 ... VLF_N_FACILITIES - 1] = VLL_INFO }, /* levels */ \ + { VLL_INFO, VLL_INFO, VLL_INFO }, /* levels */ \ VLL_INFO, /* min_level */ \ true /* honor_rate_limits */ \ };