summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-03-10 16:31:54 -0600
committerMark Salyzyn2017-03-13 12:31:09 -0500
commit501c373916e292764400dbae735f44b33378400f (patch)
tree56946d23a00461d2a462658f36689faa1d9d71a3 /logd/LogTags.h
parent488525b47ba23b2548f3bf6aa2f4ce6267b2d9b5 (diff)
downloadplatform-system-core-501c373916e292764400dbae735f44b33378400f.tar.gz
platform-system-core-501c373916e292764400dbae735f44b33378400f.tar.xz
platform-system-core-501c373916e292764400dbae735f44b33378400f.zip
logd: specify clang format
Switch _all_ file's coding style to match to ease all future changes. SideEffects: None Test: compile Bug: 35373582 Change-Id: I470cb17f64fa48f14aafc02f574e296bffe3a3f3
Diffstat (limited to 'logd/LogTags.h')
-rw-r--r--logd/LogTags.h49
1 files changed, 27 insertions, 22 deletions
diff --git a/logd/LogTags.h b/logd/LogTags.h
index 4457c462f..203318d91 100644
--- a/logd/LogTags.h
+++ b/logd/LogTags.h
@@ -17,9 +17,9 @@
17#ifndef _LOGD_LOG_TAGS_H__ 17#ifndef _LOGD_LOG_TAGS_H__
18#define _LOGD_LOG_TAGS_H__ 18#define _LOGD_LOG_TAGS_H__
19 19
20#include <string>
20#include <unordered_map> 21#include <unordered_map>
21#include <unordered_set> 22#include <unordered_set>
22#include <string>
23 23
24#include <utils/RWLock.h> 24#include <utils/RWLock.h>
25 25
@@ -35,64 +35,70 @@ class LogTags {
35 35
36 // key is Name + "+" + Format 36 // key is Name + "+" + Format
37 std::unordered_map<std::string, uint32_t> key2tag; 37 std::unordered_map<std::string, uint32_t> key2tag;
38 typedef std::unordered_map<std::string, uint32_t>::const_iterator key2tag_const_iterator; 38 typedef std::unordered_map<std::string, uint32_t>::const_iterator
39 key2tag_const_iterator;
39 40
40 // Allows us to manage access permissions based on uid registrants 41 // Allows us to manage access permissions based on uid registrants
41 // Global entries are specifically erased. 42 // Global entries are specifically erased.
42 typedef std::unordered_set<uid_t> uid_list; 43 typedef std::unordered_set<uid_t> uid_list;
43 std::unordered_map<uint32_t, uid_list> tag2uid; 44 std::unordered_map<uint32_t, uid_list> tag2uid;
44 typedef std::unordered_map<uint32_t, uid_list>::const_iterator tag2uid_const_iterator; 45 typedef std::unordered_map<uint32_t, uid_list>::const_iterator
46 tag2uid_const_iterator;
45 47
46 std::unordered_map<uint32_t, std::string> tag2name; 48 std::unordered_map<uint32_t, std::string> tag2name;
47 typedef std::unordered_map<uint32_t, std::string>::const_iterator tag2name_const_iterator; 49 typedef std::unordered_map<uint32_t, std::string>::const_iterator
50 tag2name_const_iterator;
48 51
49 std::unordered_map<uint32_t, std::string> tag2format; 52 std::unordered_map<uint32_t, std::string> tag2format;
50 typedef std::unordered_map<uint32_t, std::string>::const_iterator tag2format_const_iterator; 53 typedef std::unordered_map<uint32_t, std::string>::const_iterator
54 tag2format_const_iterator;
51 55
52 static const size_t max_per_uid = 256; // Put a cap on the tags per uid 56 static const size_t max_per_uid = 256; // Put a cap on the tags per uid
53 std::unordered_map<uid_t, size_t> uid2count; 57 std::unordered_map<uid_t, size_t> uid2count;
54 typedef std::unordered_map<uid_t, size_t>::const_iterator uid2count_const_iterator; 58 typedef std::unordered_map<uid_t, size_t>::const_iterator
59 uid2count_const_iterator;
55 60
56 // Dynamic entries are assigned 61 // Dynamic entries are assigned
57 std::unordered_map<uint32_t, size_t> tag2total; 62 std::unordered_map<uint32_t, size_t> tag2total;
58 typedef std::unordered_map<uint32_t, size_t>::const_iterator tag2total_const_iterator; 63 typedef std::unordered_map<uint32_t, size_t>::const_iterator
64 tag2total_const_iterator;
59 65
60 // emplace unique tag 66 // emplace unique tag
61 uint32_t nameToTag(uid_t uid, const char* name, const char* format); 67 uint32_t nameToTag(uid_t uid, const char* name, const char* format);
62 // find unique or associated tag 68 // find unique or associated tag
63 uint32_t nameToTag_locked(const std::string& name, const char* format, bool &unique); 69 uint32_t nameToTag_locked(const std::string& name, const char* format,
70 bool& unique);
64 71
65 // Record expected file watermarks to detect corruption. 72 // Record expected file watermarks to detect corruption.
66 std::unordered_map<std::string, size_t> file2watermark; 73 std::unordered_map<std::string, size_t> file2watermark;
67 typedef std::unordered_map<std::string, size_t>::const_iterator file2watermark_const_iterator; 74 typedef std::unordered_map<std::string, size_t>::const_iterator
75 file2watermark_const_iterator;
68 76
69 void ReadPersistEventLogTags(); 77 void ReadPersistEventLogTags();
70 78
71 // format helpers 79 // format helpers
72 // format a single entry, does not need object data 80 // format a single entry, does not need object data
73 static std::string formatEntry(uint32_t tag, uid_t uid, 81 static std::string formatEntry(uint32_t tag, uid_t uid, const char* name,
74 const char* name, const char* format); 82 const char* format);
75 // caller locks, database lookup, authenticate against uid 83 // caller locks, database lookup, authenticate against uid
76 std::string formatEntry_locked(uint32_t tag, uid_t uid, 84 std::string formatEntry_locked(uint32_t tag, uid_t uid,
77 bool authenticate = true); 85 bool authenticate = true);
78 86
79 bool RebuildFileEventLogTags(const char* filename, bool warn = true); 87 bool RebuildFileEventLogTags(const char* filename, bool warn = true);
80 88
81 void AddEventLogTags(uint32_t tag, uid_t uid, 89 void AddEventLogTags(uint32_t tag, uid_t uid, const std::string& Name,
82 const std::string& Name, const std::string& Format, 90 const std::string& Format, const char* source = NULL,
83 const char* source = NULL, bool warn = false); 91 bool warn = false);
84 92
85 void WriteDynamicEventLogTags(uint32_t tag, uid_t uid); 93 void WriteDynamicEventLogTags(uint32_t tag, uid_t uid);
86 void WriteDebugEventLogTags(uint32_t tag, uid_t uid); 94 void WriteDebugEventLogTags(uint32_t tag, uid_t uid);
87 // push tag details to persistent storage 95 // push tag details to persistent storage
88 void WritePersistEventLogTags(uint32_t tag, 96 void WritePersistEventLogTags(uint32_t tag, uid_t uid = AID_ROOT,
89 uid_t uid = AID_ROOT,
90 const char* source = NULL); 97 const char* source = NULL);
91 98
92 static const uint32_t emptyTag = uint32_t(-1); 99 static const uint32_t emptyTag = uint32_t(-1);
93 100
94public: 101 public:
95
96 static const char system_event_log_tags[]; 102 static const char system_event_log_tags[];
97 static const char dynamic_event_log_tags[]; 103 static const char dynamic_event_log_tags[];
98 // Only for userdebug and eng 104 // Only for userdebug and eng
@@ -111,9 +117,8 @@ public:
111 uint32_t nameToTag(const char* name) const; 117 uint32_t nameToTag(const char* name) const;
112 118
113 // emplace tag if necessary, provide event-log-tag formated output in string 119 // emplace tag if necessary, provide event-log-tag formated output in string
114 std::string formatGetEventTag(uid_t uid, 120 std::string formatGetEventTag(uid_t uid, const char* name,
115 const char* name,
116 const char* format); 121 const char* format);
117}; 122};
118 123
119#endif // _LOGD_LOG_TAGS_H__ 124#endif // _LOGD_LOG_TAGS_H__