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

Side by Side Diff: base/vlog.h

Issue 6085015: Order function definitions in base/ according to the header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lrn2merge Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/tracked_objects.cc ('k') | base/vlog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef BASE_VLOG_H_ 5 #ifndef BASE_VLOG_H_
6 #define BASE_VLOG_H_ 6 #define BASE_VLOG_H_
7 #pragma once 7 #pragma once
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/string_piece.h" 14 #include "base/string_piece.h"
15 15
16 namespace logging { 16 namespace logging {
17 17
18 // A helper class containing all the settings for vlogging. 18 // A helper class containing all the settings for vlogging.
19 class VlogInfo { 19 class VlogInfo {
20 public: 20 public:
21 static const int kDefaultVlogLevel;
22
21 // |v_switch| gives the default maximal active V-logging level; 0 is 23 // |v_switch| gives the default maximal active V-logging level; 0 is
22 // the default. Normally positive values are used for V-logging 24 // the default. Normally positive values are used for V-logging
23 // levels. 25 // levels.
24 // 26 //
25 // |vmodule_switch| gives the per-module maximal V-logging levels to 27 // |vmodule_switch| gives the per-module maximal V-logging levels to
26 // override the value given by |v_switch|. 28 // override the value given by |v_switch|.
27 // E.g. "my_module=2,foo*=3" would change the logging level for all 29 // E.g. "my_module=2,foo*=3" would change the logging level for all
28 // code in source files "my_module.*" and "foo*.*" ("-inl" suffixes 30 // code in source files "my_module.*" and "foo*.*" ("-inl" suffixes
29 // are also disregarded for this matching). 31 // are also disregarded for this matching).
30 // 32 //
31 // |log_severity| points to an int that stores the log level. If a valid 33 // |log_severity| points to an int that stores the log level. If a valid
32 // |v_switch| is provided, it will set the log level, and the default 34 // |v_switch| is provided, it will set the log level, and the default
33 // vlog severity will be read from there.. 35 // vlog severity will be read from there..
34 // 36 //
35 // Any pattern containing a forward or backward slash will be tested 37 // Any pattern containing a forward or backward slash will be tested
36 // against the whole pathname and not just the module. E.g., 38 // against the whole pathname and not just the module. E.g.,
37 // "*/foo/bar/*=2" would change the logging level for all code in 39 // "*/foo/bar/*=2" would change the logging level for all code in
38 // source files under a "foo/bar" directory. 40 // source files under a "foo/bar" directory.
39 VlogInfo(const std::string& v_switch, 41 VlogInfo(const std::string& v_switch,
40 const std::string& vmodule_switch, 42 const std::string& vmodule_switch,
41 int* min_log_level); 43 int* min_log_level);
42 ~VlogInfo(); 44 ~VlogInfo();
43 45
44 // Returns the vlog level for a given file (usually taken from 46 // Returns the vlog level for a given file (usually taken from
45 // __FILE__). 47 // __FILE__).
46 int GetVlogLevel(const base::StringPiece& file) const; 48 int GetVlogLevel(const base::StringPiece& file) const;
47 49
48 static const int kDefaultVlogLevel;
49
50 private: 50 private:
51 void SetMaxVlogLevel(int level); 51 void SetMaxVlogLevel(int level);
52 int GetMaxVlogLevel() const; 52 int GetMaxVlogLevel() const;
53 53
54 // VmodulePattern holds all the information for each pattern parsed 54 // VmodulePattern holds all the information for each pattern parsed
55 // from |vmodule_switch|. 55 // from |vmodule_switch|.
56 struct VmodulePattern { 56 struct VmodulePattern;
57 enum MatchTarget { MATCH_MODULE, MATCH_FILE };
58
59 explicit VmodulePattern(const std::string& pattern);
60
61 VmodulePattern();
62
63 std::string pattern;
64 int vlog_level;
65 MatchTarget match_target;
66 };
67
68 std::vector<VmodulePattern> vmodule_levels_; 57 std::vector<VmodulePattern> vmodule_levels_;
69 int* min_log_level_; 58 int* min_log_level_;
70 59
71 DISALLOW_COPY_AND_ASSIGN(VlogInfo); 60 DISALLOW_COPY_AND_ASSIGN(VlogInfo);
72 }; 61 };
73 62
74 // Returns true if the string passed in matches the vlog pattern. The 63 // Returns true if the string passed in matches the vlog pattern. The
75 // vlog pattern string can contain wildcards like * and ?. ? matches 64 // vlog pattern string can contain wildcards like * and ?. ? matches
76 // exactly one character while * matches 0 or more characters. Also, 65 // exactly one character while * matches 0 or more characters. Also,
77 // as a special case, a / or \ character matches either / or \. 66 // as a special case, a / or \ character matches either / or \.
78 // 67 //
79 // Examples: 68 // Examples:
80 // "kh?n" matches "khan" but not "khn" or "khaan" 69 // "kh?n" matches "khan" but not "khn" or "khaan"
81 // "kh*n" matches "khn", "khan", or even "khaaaaan" 70 // "kh*n" matches "khn", "khan", or even "khaaaaan"
82 // "/foo\bar" matches "/foo/bar", "\foo\bar", or "/foo\bar" 71 // "/foo\bar" matches "/foo/bar", "\foo\bar", or "/foo\bar"
83 // (disregarding C escaping rules) 72 // (disregarding C escaping rules)
84 bool MatchVlogPattern(const base::StringPiece& string, 73 bool MatchVlogPattern(const base::StringPiece& string,
85 const base::StringPiece& vlog_pattern); 74 const base::StringPiece& vlog_pattern);
86 75
87 } // namespace logging 76 } // namespace logging
88 77
89 #endif // BASE_VLOG_H_ 78 #endif // BASE_VLOG_H_
OLDNEW
« no previous file with comments | « base/tracked_objects.cc ('k') | base/vlog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698