summaryrefslogtreecommitdiffstats
path: root/base/logging.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 19:26:36 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 19:26:36 +0000
commit99b7c57fda118a1507d30b59e29005fdd2a73f7c (patch)
treef6d93b1690eb4395d1edb7c6c24f32d093421f92 /base/logging.cc
parentcca1256e67bcdc4b1ce6be8cd4494b3cffa60198 (diff)
downloadchromium_src-99b7c57fda118a1507d30b59e29005fdd2a73f7c.zip
chromium_src-99b7c57fda118a1507d30b59e29005fdd2a73f7c.tar.gz
chromium_src-99b7c57fda118a1507d30b59e29005fdd2a73f7c.tar.bz2
Implemented VLOG() et al.
Implemented VLOG(), VLOG_IF(), VLOG_IS_ON(). Added --v and --vmodule switches. Changed some spammy sync-related logs to use VLOG. BUG=56965 TEST=New unittests Review URL: http://codereview.chromium.org/3448028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.cc')
-rw-r--r--base/logging.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/base/logging.cc b/base/logging.cc
index 780da86..a94d5f35 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -51,10 +51,12 @@ typedef pthread_mutex_t* MutexHandle;
#include "base/process_util.h"
#include "base/string_piece.h"
#include "base/utf_string_conversions.h"
+#include "base/vlog.h"
namespace logging {
bool g_enable_dcheck = false;
+VlogInfo* g_vlog_info = NULL;
const char* const log_severity_names[LOG_NUM_SEVERITIES] = {
"INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" };
@@ -329,8 +331,20 @@ void BaseInitLoggingImpl(const PathChar* new_log_file,
LoggingDestination logging_dest,
LogLockingState lock_log,
OldFileDeletionState delete_old) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
g_enable_dcheck =
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableDCHECK);
+ command_line->HasSwitch(switches::kEnableDCHECK);
+ delete g_vlog_info;
+ g_vlog_info = NULL;
+ // Don't bother initializing g_vlog_info unless we use one of the
+ // vlog switches.
+ if (command_line->HasSwitch(switches::kV) ||
+ command_line->HasSwitch(switches::kVModule)) {
+ g_vlog_info =
+ new VlogInfo(command_line->GetSwitchValueASCII(switches::kV),
+ command_line->GetSwitchValueASCII(switches::kVModule));
+ }
+
LoggingLock::Init(lock_log, new_log_file);
LoggingLock logging_lock;
@@ -367,6 +381,13 @@ int GetMinLogLevel() {
return min_log_level;
}
+int GetVlogLevelHelper(const char* file, size_t N) {
+ DCHECK_GT(N, 0U);
+ return g_vlog_info ?
+ g_vlog_info->GetVlogLevel(base::StringPiece(file, N - 1)) :
+ VlogInfo::kDefaultVlogLevel;
+}
+
void SetLogFilterPrefix(const char* filter) {
if (log_filter_prefix) {
delete log_filter_prefix;