Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Unified Diff: base/logging.cc

Issue 3448028: Implemented VLOG() et al. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Addressed evmar's comments Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/logging.h ('k') | base/string_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.cc
diff --git a/base/logging.cc b/base/logging.cc
index 780da868af49a9e5dbdb414abcd3f00f081f3f0f..a94d5f35e16e9848bb51665fd639e2b3f2396847 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;
« no previous file with comments | « base/logging.h ('k') | base/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698