Fix a bug: vmodule didn't work with gflags. Since
gflags isn't initialized when REGISTER_MODULE_INITIALIZER is invoked, we couldn't initialize vmodule_list properly. Modified to call VLOG2Initializer in the first call of InitVLOG3__. git-svn-id: https://google-glog.googlecode.com/svn/trunk@8 eb4d4688-79bd-11dd-afb4-1d65580434c0
This commit is contained in:
parent
364832195d
commit
2ed196e07a
@ -88,8 +88,9 @@ static VModuleInfo* vmodule_list = 0;
|
|||||||
// Boolean initialization flag.
|
// Boolean initialization flag.
|
||||||
static bool inited_vmodule = false;
|
static bool inited_vmodule = false;
|
||||||
|
|
||||||
|
// L >= vmodule_lock.
|
||||||
static void VLOG2Initializer() {
|
static void VLOG2Initializer() {
|
||||||
MutexLock l(&vmodule_lock);
|
vmodule_lock.AssertHeld();
|
||||||
// Can now parse --vmodule flag and initialize mapping of module-specific
|
// Can now parse --vmodule flag and initialize mapping of module-specific
|
||||||
// logging levels.
|
// logging levels.
|
||||||
inited_vmodule = false;
|
inited_vmodule = false;
|
||||||
@ -120,8 +121,6 @@ static void VLOG2Initializer() {
|
|||||||
inited_vmodule = true;
|
inited_vmodule = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_MODULE_INITIALIZER(vlog_is_on, VLOG2Initializer());
|
|
||||||
|
|
||||||
// This can be called very early, so we use SpinLock and RAW_VLOG here.
|
// This can be called very early, so we use SpinLock and RAW_VLOG here.
|
||||||
int SetVLOGLevel(const char* module_pattern, int log_level) {
|
int SetVLOGLevel(const char* module_pattern, int log_level) {
|
||||||
int result = FLAGS_v;
|
int result = FLAGS_v;
|
||||||
@ -161,12 +160,8 @@ bool InitVLOG3__(int32** site_flag, int32* site_default,
|
|||||||
const char* fname, int32 verbose_level) {
|
const char* fname, int32 verbose_level) {
|
||||||
MutexLock l(&vmodule_lock);
|
MutexLock l(&vmodule_lock);
|
||||||
bool read_vmodule_flag = inited_vmodule;
|
bool read_vmodule_flag = inited_vmodule;
|
||||||
if (!read_vmodule_flag && vmodule_list == 0) {
|
if (!read_vmodule_flag) {
|
||||||
// The command line --vmodule flags haven't been parsed
|
VLOG2Initializer();
|
||||||
// and nothing was set with SetVLOGLevel yet,
|
|
||||||
// but *site_default (usually FLAGS_v) might be manually set
|
|
||||||
// by some early-executing code, or else it's still 0.
|
|
||||||
return *site_default >= verbose_level;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// protect the errno global in case someone writes:
|
// protect the errno global in case someone writes:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user