X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fvlog_is_on.cc;h=4c95583b6838d974c261c2c926c7b24b17d6d326;hb=e209906823b9144e955f9e01fedd90281c6d54c8;hp=38a65a32336caa72e8e90377a320599eeeb04b93;hpb=f365379532ad3c0d86fa1b52434392df256166b4;p=platform%2Fupstream%2Fglog.git diff --git a/src/vlog_is_on.cc b/src/vlog_is_on.cc index 38a65a3..4c95583 100644 --- a/src/vlog_is_on.cc +++ b/src/vlog_is_on.cc @@ -49,10 +49,10 @@ using std::string; -DEFINE_int32(v, 0, "Show all VLOG(m) messages for m <= this." +GLOG_DEFINE_int32(v, 0, "Show all VLOG(m) messages for m <= this." " Overridable by --vmodule."); -DEFINE_string(vmodule, "", "per-module verbose level." +GLOG_DEFINE_string(vmodule, "", "per-module verbose level." " Argument is a comma-separated list of =." " is a glob pattern, matched against the filename base" " (that is, name ignoring .cc/.h./-inl.h)." @@ -70,8 +70,8 @@ GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern, size_t patt_len, const char* str, size_t str_len) { - int p = 0; - int s = 0; + size_t p = 0; + size_t s = 0; while (1) { if (p == patt_len && s == str_len) return true; if (p == patt_len) return false; @@ -162,30 +162,32 @@ int SetVLOGLevel(const char* module_pattern, int log_level) { int result = FLAGS_v; int const pattern_len = strlen(module_pattern); bool found = false; - MutexLock l(&vmodule_lock); // protect whole read-modify-write - for (const VModuleInfo* info = vmodule_list; - info != NULL; info = info->next) { - if (info->module_pattern == module_pattern) { - if (!found) { + { + MutexLock l(&vmodule_lock); // protect whole read-modify-write + for (const VModuleInfo* info = vmodule_list; + info != NULL; info = info->next) { + if (info->module_pattern == module_pattern) { + if (!found) { + result = info->vlog_level; + found = true; + } + info->vlog_level = log_level; + } else if (!found && + SafeFNMatch_(info->module_pattern.c_str(), + info->module_pattern.size(), + module_pattern, pattern_len)) { result = info->vlog_level; found = true; } + } + if (!found) { + VModuleInfo* info = new VModuleInfo; + info->module_pattern = module_pattern; info->vlog_level = log_level; - } else if (!found && - SafeFNMatch_(info->module_pattern.c_str(), - info->module_pattern.size(), - module_pattern, pattern_len)) { - result = info->vlog_level; - found = true; + info->next = vmodule_list; + vmodule_list = info; } } - if (!found) { - VModuleInfo* info = new VModuleInfo; - info->module_pattern = module_pattern; - info->vlog_level = log_level; - info->next = vmodule_list; - vmodule_list = info; - } RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level); return result; } @@ -211,7 +213,7 @@ bool InitVLOG3__(int32** site_flag, int32* site_default, const char* base = strrchr(fname, '/'); base = base ? (base+1) : fname; const char* base_end = strchr(base, '.'); - size_t base_length = base_end ? (base_end - base) : strlen(base); + size_t base_length = base_end ? size_t(base_end - base) : strlen(base); // Trim out trailing "-inl" if any if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) {