23#include "absl/synchronization/mutex.h"
31#define ANNOTATE_BENIGN_RACE(address, description)
36 "Show all VLOG(m) messages for m <= this."
37 " Overridable by --vmodule.");
40 "per-module verbose level."
41 " Argument is a comma-separated list of <module name>=<log level>."
42 " <module name> is a glob pattern, matched against the filename base"
43 " (that is, name ignoring .cc/.h./-inl.h)."
44 " <log level> overrides any value given by --v.");
48namespace logging_internal {
52 const char* str,
size_t str_len);
59 const char* str,
size_t str_len) {
63 if (p == patt_len && s == str_len)
return true;
64 if (p == patt_len)
return false;
65 if (s == str_len)
return p + 1 == patt_len && pattern[p] ==
'*';
66 if (pattern[p] == str[s] || pattern[p] ==
'?') {
71 if (pattern[p] ==
'*') {
72 if (p + 1 == patt_len)
return true;
74 if (
SafeFNMatch_(pattern + (p + 1), patt_len - (p + 1), str + s,
79 }
while (s != str_len);
121 const char* vmodule = absl::GetFlag(FLAGS_vmodule).c_str();
125 while ((sep = strchr(vmodule,
'=')) != NULL) {
126 string pattern(vmodule, sep - vmodule);
128 if (sscanf(sep,
"=%d", &module_level) == 1) {
139 vmodule = strchr(sep,
',');
140 if (vmodule == NULL)
break;
152 int result = absl::GetFlag(FLAGS_v);
153 int const pattern_len = strlen(module_pattern);
159 if (info->module_pattern == module_pattern) {
161 result = info->vlog_level;
164 info->vlog_level = log_level;
165 }
else if (!found &&
SafeFNMatch_(info->module_pattern.c_str(),
166 info->module_pattern.size(),
167 module_pattern, pattern_len)) {
168 result = info->vlog_level;
180 RAW_VLOG(1,
"Set VLOG level for \"%s\" to %d", module_pattern, log_level);
187 int32 verbose_level) {
190 if (!read_vmodule_flag) {
196 int old_errno = errno;
199 int32* site_flag_value = site_default;
202 const char* base = strrchr(fname,
'/');
203 base = base ? (base + 1) : fname;
204 const char* base_end = strchr(base,
'.');
205 size_t base_length = base_end ? size_t(base_end - base) : strlen(base);
208 if (base_length >= 4 && (memcmp(base + base_length - 4,
"-inl", 4) == 0)) {
219 if (
SafeFNMatch_(info->module_pattern.c_str(), info->module_pattern.size(),
220 base, base_length)) {
221 site_flag_value = &info->vlog_level;
230 "*site_flag may be written by several threads,"
231 " but the value will be the same");
232 if (read_vmodule_flag) *site_flag = site_flag_value;
237 return *site_flag_value >= verbose_level;
#define GOOGLE_GLOG_DLL_DECL
GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char *pattern, size_t patt_len, const char *str, size_t str_len)
static absl::Mutex vmodule_lock
bool InitVLOG3__(int32 **site_flag, int32 *site_default, const char *fname, int32 verbose_level)
int32 kLogSiteUninitialized
static bool inited_vmodule
static VModuleInfo * vmodule_list
int SetVLOGLevel(const char *module_pattern, int log_level)
static void VLOG2Initializer()
#define RAW_VLOG(verboselevel,...)
#define ANNOTATE_BENIGN_RACE(address, description)
ABSL_FLAG(int, v, 0, "Show all VLOG(m) messages for m <= this." " Overridable by --vmodule.")