mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-21 11:23:47 +08:00
loggerd: fix ~0.5s startup logging delay (#38649)
This commit is contained in:
@@ -15,7 +15,7 @@ public:
|
||||
|
||||
static std::string get_serial() { return "cccccc"; }
|
||||
|
||||
static std::map<std::string, std::string> get_init_logs() {
|
||||
static std::map<std::string, std::string> get_init_logs(bool route_log = false) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
std::ofstream("/sys/class/leds/led:switch_2/brightness") << value << "\n";
|
||||
}
|
||||
|
||||
static std::map<std::string, std::string> get_init_logs() {
|
||||
static std::map<std::string, std::string> get_init_logs(bool route_log = false) {
|
||||
std::map<std::string, std::string> ret = {
|
||||
{"/BUILD", util::read_file("/BUILD")},
|
||||
{"lsblk", util::check_output("lsblk -o NAME,SIZE,STATE,VENDOR,MODEL,REV,SERIAL")},
|
||||
@@ -73,12 +73,14 @@ public:
|
||||
temp.erase(temp.find_last_not_of(std::string("\0\r\n", 3))+1);
|
||||
ret["boot temp"] = temp;
|
||||
|
||||
// TODO: log something from system and boot
|
||||
for (std::string part : {"xbl", "abl", "aop", "devcfg", "xbl_config"}) {
|
||||
for (std::string slot : {"a", "b"}) {
|
||||
std::string partition = part + "_" + slot;
|
||||
std::string hash = util::check_output("sha256sum /dev/disk/by-partlabel/" + partition);
|
||||
ret[partition] = hash.substr(0, hash.find_first_of(" "));
|
||||
// TODO: these are too slow to do on route log inits. need to do it async?
|
||||
if (!route_log) {
|
||||
for (std::string part : {"xbl", "abl", "aop", "devcfg", "xbl_config"}) {
|
||||
for (std::string slot : {"a", "b"}) {
|
||||
std::string partition = part + "_" + slot;
|
||||
std::string hash = util::check_output("sha256sum /dev/disk/by-partlabel/" + partition);
|
||||
ret[partition] = hash.substr(0, hash.find_first_of(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "common/version.h"
|
||||
|
||||
// ***** log metadata *****
|
||||
kj::Array<capnp::word> logger_build_init_data() {
|
||||
kj::Array<capnp::word> logger_build_init_data(bool route_log) {
|
||||
uint64_t wall_time = nanos_since_epoch();
|
||||
|
||||
MessageBuilder msg;
|
||||
@@ -70,7 +70,7 @@ kj::Array<capnp::word> logger_build_init_data() {
|
||||
"df -h", // usage for all filesystems
|
||||
};
|
||||
|
||||
auto hw_logs = Hardware::get_init_logs();
|
||||
auto hw_logs = Hardware::get_init_logs(route_log);
|
||||
|
||||
auto commands = init.initCommands().initEntries(log_commands.size() + hw_logs.size());
|
||||
for (int i = 0; i < log_commands.size(); i++) {
|
||||
@@ -164,7 +164,7 @@ static void log_sentinel(LoggerState *log, SentinelType type, int exit_signal =
|
||||
LoggerState::LoggerState(const std::string &log_root) {
|
||||
route_name = logger_get_identifier("RouteCount");
|
||||
route_path = log_root + "/" + route_name;
|
||||
init_data = logger_build_init_data();
|
||||
init_data = logger_build_init_data(true);
|
||||
}
|
||||
|
||||
LoggerState::~LoggerState() {
|
||||
|
||||
@@ -32,6 +32,6 @@ protected:
|
||||
std::unique_ptr<ZstdFileWriter> rlog, qlog;
|
||||
};
|
||||
|
||||
kj::Array<capnp::word> logger_build_init_data();
|
||||
kj::Array<capnp::word> logger_build_init_data(bool route_log = false);
|
||||
std::string logger_get_identifier(std::string key);
|
||||
std::string zstd_decompress(const std::string &in);
|
||||
|
||||
Reference in New Issue
Block a user