summaryrefslogtreecommitdiffstats
path: root/base/vlog.h
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/vlog.h
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/vlog.h')
-rw-r--r--base/vlog.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/base/vlog.h b/base/vlog.h
new file mode 100644
index 0000000..faa62ec
--- /dev/null
+++ b/base/vlog.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_VLOG_H_
+#define BASE_VLOG_H_
+#pragma once
+
+#include <cstddef>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/string_piece.h"
+
+namespace logging {
+
+// A helper class containing all the settings for vlogging.
+class VlogInfo {
+ public:
+ // |v_switch| gives the default maximal active V-logging level; 0 is
+ // the default. Normally positive values are used for V-logging
+ // levels.
+ //
+ // |vmodule_switch| gives the per-module maximal V-logging levels to
+ // override the value given by |v_switch|.
+ // E.g. "my_module=2,foo*=3" would change the logging level for all
+ // code in source files "my_module.*" and "foo*.*" ("-inl" suffixes
+ // are also disregarded for this matching).
+ VlogInfo(const std::string& v_switch,
+ const std::string& vmodule_switch);
+
+ // Returns the vlog level for a given file (usually taken from
+ // __FILE__).
+ int GetVlogLevel(const base::StringPiece& file);
+
+ static const int kDefaultVlogLevel;
+
+ private:
+ typedef std::pair<std::string, int> VmodulePattern;
+
+ int max_vlog_level_;
+ std::vector<VmodulePattern> vmodule_levels_;
+
+ DISALLOW_COPY_AND_ASSIGN(VlogInfo);
+};
+
+} // namespace logging
+
+#endif // BASE_VLOG_H_