| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/vlog.h" | 5 #include "base/vlog.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 VlogInfo::VmodulePattern::VmodulePattern() | 43 VlogInfo::VmodulePattern::VmodulePattern() |
| 44 : vlog_level(VlogInfo::kDefaultVlogLevel), | 44 : vlog_level(VlogInfo::kDefaultVlogLevel), |
| 45 match_target(MATCH_MODULE) {} | 45 match_target(MATCH_MODULE) {} |
| 46 | 46 |
| 47 VlogInfo::VlogInfo(const std::string& v_switch, | 47 VlogInfo::VlogInfo(const std::string& v_switch, |
| 48 const std::string& vmodule_switch, | 48 const std::string& vmodule_switch, |
| 49 int* min_log_level) | 49 int* min_log_level) |
| 50 : min_log_level_(min_log_level) { | 50 : min_log_level_(min_log_level) { |
| 51 DCHECK(min_log_level != NULL); | 51 DCHECK(min_log_level != NULL); |
| 52 | 52 |
| 53 typedef std::pair<std::string, std::string> KVPair; | |
| 54 int vlog_level = 0; | 53 int vlog_level = 0; |
| 55 if (!v_switch.empty()) { | 54 if (!v_switch.empty()) { |
| 56 if (base::StringToInt(v_switch, &vlog_level)) { | 55 if (base::StringToInt(v_switch, &vlog_level)) { |
| 57 SetMaxVlogLevel(vlog_level); | 56 SetMaxVlogLevel(vlog_level); |
| 58 } else { | 57 } else { |
| 59 DLOG(WARNING) << "Could not parse v switch \"" << v_switch << "\""; | 58 DLOG(WARNING) << "Could not parse v switch \"" << v_switch << "\""; |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 | 61 |
| 63 std::vector<KVPair> kv_pairs; | 62 base::StringPairs kv_pairs; |
| 64 if (!base::SplitStringIntoKeyValuePairs( | 63 if (!base::SplitStringIntoKeyValuePairs( |
| 65 vmodule_switch, '=', ',', &kv_pairs)) { | 64 vmodule_switch, '=', ',', &kv_pairs)) { |
| 66 DLOG(WARNING) << "Could not fully parse vmodule switch \"" | 65 DLOG(WARNING) << "Could not fully parse vmodule switch \"" |
| 67 << vmodule_switch << "\""; | 66 << vmodule_switch << "\""; |
| 68 } | 67 } |
| 69 for (std::vector<KVPair>::const_iterator it = kv_pairs.begin(); | 68 for (base::StringPairs::const_iterator it = kv_pairs.begin(); |
| 70 it != kv_pairs.end(); ++it) { | 69 it != kv_pairs.end(); ++it) { |
| 71 VmodulePattern pattern(it->first); | 70 VmodulePattern pattern(it->first); |
| 72 if (!base::StringToInt(it->second, &pattern.vlog_level)) { | 71 if (!base::StringToInt(it->second, &pattern.vlog_level)) { |
| 73 DLOG(WARNING) << "Parsed vlog level for \"" | 72 DLOG(WARNING) << "Parsed vlog level for \"" |
| 74 << it->first << "=" << it->second | 73 << it->first << "=" << it->second |
| 75 << "\" as " << pattern.vlog_level; | 74 << "\" as " << pattern.vlog_level; |
| 76 } | 75 } |
| 77 vmodule_levels_.push_back(pattern); | 76 vmodule_levels_.push_back(pattern); |
| 78 } | 77 } |
| 79 } | 78 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 if (MatchVlogPattern(s, p)) | 171 if (MatchVlogPattern(s, p)) |
| 173 return true; | 172 return true; |
| 174 s.remove_prefix(1); | 173 s.remove_prefix(1); |
| 175 } | 174 } |
| 176 | 175 |
| 177 // Otherwise, we couldn't find a match. | 176 // Otherwise, we couldn't find a match. |
| 178 return false; | 177 return false; |
| 179 } | 178 } |
| 180 | 179 |
| 181 } // namespace logging | 180 } // namespace logging |
| OLD | NEW |