loggerd: implement DONT_LOG flag (#21832)

* implement DONT_LOG flag

* better typing
pull/21834/head
George Hotz 2021-08-02 20:16:38 -07:00 committed by GitHub
parent 77a38b3f87
commit 8354cfc53c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -146,7 +146,7 @@ private:
};
std::unordered_map<std::string, uint32_t> keys = {
{"AccessToken", CLEAR_ON_MANAGER_START},
{"AccessToken", CLEAR_ON_MANAGER_START | DONT_LOG},
{"ApiCache_DriveStats", PERSISTENT},
{"ApiCache_Device", PERSISTENT},
{"ApiCache_Owner", PERSISTENT},
@ -191,7 +191,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"LastUpdateException", PERSISTENT},
{"LastUpdateTime", PERSISTENT},
{"LiveParameters", PERSISTENT},
{"MapboxToken", PERSISTENT},
{"MapboxToken", PERSISTENT | DONT_LOG},
{"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF},
{"NavSettingTime24h", PERSISTENT},
{"OpenpilotEnabledToggle", PERSISTENT},
@ -246,6 +246,10 @@ bool Params::checkKey(const std::string &key) {
return keys.find(key) != keys.end();
}
ParamKeyType Params::getKeyType(const std::string &key) {
return static_cast<ParamKeyType>(keys[key]);
}
int Params::put(const char* key, const char* value, size_t value_size) {
// Information about safely and atomically writing a file: https://lwn.net/Articles/457667/
// 1) Create temp file

View File

@ -12,7 +12,8 @@ enum ParamKeyType {
CLEAR_ON_PANDA_DISCONNECT = 0x08,
CLEAR_ON_IGNITION_ON = 0x10,
CLEAR_ON_IGNITION_OFF = 0x20,
ALL = 0x02 | 0x04 | 0x08 | 0x10 | 0x20
DONT_LOG = 0x40,
ALL = 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40
};
class Params {
@ -24,6 +25,7 @@ public:
Params(const std::string &path);
bool checkKey(const std::string &key);
ParamKeyType getKeyType(const std::string &key);
// Delete a value
int remove(const char *key);

View File

@ -108,7 +108,9 @@ kj::Array<capnp::word> logger_build_init_data() {
for (auto& [key, value] : params_map) {
auto lentry = lparams[i];
lentry.setKey(key);
lentry.setValue(capnp::Data::Reader((const kj::byte*)value.data(), value.size()));
if ( !(params.getKeyType(key) & DONT_LOG) ) {
lentry.setValue(capnp::Data::Reader((const kj::byte*)value.data(), value.size()));
}
i++;
}