Files
dragonpilot/selfdrive/loggerd/bootlog.cc
Dean Lee f973c56a36 loggerd: split bootlog to a separate program (#19831)
* bootlog

* blank lines

* move file_exists to util.h

* src = ['loggerd.cc']

* log_init_data

* Revert "src = ['loggerd.cc']"

This reverts commit 18a587023d75b3a3a54f1ceaf9cb31a51640a067.

* add bootlog to .gitignore

* use s->has_qlog instead of true

* add blank lines & remove extern C
2021-01-19 12:16:12 -08:00

38 lines
1.1 KiB
C++

#include <assert.h>
#include <string>
#include "common/swaglog.h"
#include "common/util.h"
#include "logger.h"
#include "messaging.hpp"
int main(int argc, char** argv) {
LoggerState logger;
logger_init(&logger, "bootlog", false);
char segment_path[4096];
int err = logger_next(&logger, LOG_ROOT.c_str(), segment_path, sizeof(segment_path), nullptr);
assert(err == 0);
LOGW("bootlog to %s", segment_path);
MessageBuilder msg;
auto boot = msg.initEvent().initBoot();
boot.setWallTimeNanos(nanos_since_epoch());
std::string lastKmsg = util::read_file("/sys/fs/pstore/console-ramoops");
boot.setLastKmsg(capnp::Data::Reader((const kj::byte*)lastKmsg.data(), lastKmsg.size()));
std::string lastPmsg = util::read_file("/sys/fs/pstore/pmsg-ramoops-0");
boot.setLastPmsg(capnp::Data::Reader((const kj::byte*)lastPmsg.data(), lastPmsg.size()));
std::string launchLog = util::read_file("/tmp/launch_log");
boot.setLaunchLog(capnp::Text::Reader(launchLog.data(), launchLog.size()));
auto bytes = msg.toBytes();
logger_log(&logger, bytes.begin(), bytes.size(), false);
logger_close(&logger);
return 0;
}