diff options
author | siggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-04 15:50:49 +0000 |
---|---|---|
committer | siggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-04 15:50:49 +0000 |
commit | 162ac0f02a2a7a6f1909a85a222ab5da3d280d12 (patch) | |
tree | ccc49648b2197f598acaeafa4d4f58c0c0048bdd /base/vlog.cc | |
parent | ce833284bfd1b0a5db62e0f3c25f48af70ae8784 (diff) | |
download | chromium_src-162ac0f02a2a7a6f1909a85a222ab5da3d280d12.zip chromium_src-162ac0f02a2a7a6f1909a85a222ab5da3d280d12.tar.gz chromium_src-162ac0f02a2a7a6f1909a85a222ab5da3d280d12.tar.bz2 |
Integrate ETW with VLOG logging.
This change extends the log severities into the negative for VLOG verbosities.
It also keeps track of file/line information and passes it to any registered log handler.
The log level is naturally controlled by translating ETW log levels to the severities.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/4164011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/vlog.cc')
-rw-r--r-- | base/vlog.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/base/vlog.cc b/base/vlog.cc index 8c615cb..cda9cea 100644 --- a/base/vlog.cc +++ b/base/vlog.cc @@ -29,14 +29,20 @@ VlogInfo::VmodulePattern::VmodulePattern() match_target(MATCH_MODULE) {} VlogInfo::VlogInfo(const std::string& v_switch, - const std::string& vmodule_switch) - : max_vlog_level_(kDefaultVlogLevel) { + const std::string& vmodule_switch, + int* min_log_level) + : min_log_level_(min_log_level) { + DCHECK(min_log_level != NULL); + typedef std::pair<std::string, std::string> KVPair; - if (!v_switch.empty() && - !base::StringToInt(v_switch, &max_vlog_level_)) { + int vlog_level = 0; + if (base::StringToInt(v_switch, &vlog_level)) { + SetMaxVlogLevel(vlog_level); + } else { LOG(WARNING) << "Parsed v switch \"" - << v_switch << "\" as " << max_vlog_level_; + << v_switch << "\" as " << vlog_level; } + std::vector<KVPair> kv_pairs; if (!base::SplitStringIntoKeyValuePairs( vmodule_switch, '=', ',', &kv_pairs)) { @@ -57,6 +63,15 @@ VlogInfo::VlogInfo(const std::string& v_switch, VlogInfo::~VlogInfo() {} +void VlogInfo::SetMaxVlogLevel(int level) { + // Log severity is the negative verbosity. + *min_log_level_ = -level; +} + +int VlogInfo::GetMaxVlogLevel() const { + return -*min_log_level_; +} + namespace { // Given a path, returns the basename with the extension chopped off @@ -79,7 +94,7 @@ base::StringPiece GetModule(const base::StringPiece& file) { } // namespace -int VlogInfo::GetVlogLevel(const base::StringPiece& file) { +int VlogInfo::GetVlogLevel(const base::StringPiece& file) const { if (!vmodule_levels_.empty()) { base::StringPiece module(GetModule(file)); for (std::vector<VmodulePattern>::const_iterator it = @@ -90,7 +105,7 @@ int VlogInfo::GetVlogLevel(const base::StringPiece& file) { return it->vlog_level; } } - return max_vlog_level_; + return GetMaxVlogLevel(); } bool MatchVlogPattern(const base::StringPiece& string, |